Skip to content

Commit 8d9578c

Browse files
committed
Disable form submission on validation error
1 parent 6624ff6 commit 8d9578c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

packages/sprinkle-account/app/assets/composables/useUserProfileEditApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import schemaFile from '../../schema/requests/profile-settings.yaml?raw'
1212
* API Composable
1313
*/
1414
export function useUserProfileEditApi() {
15-
const apiLoading = ref<Boolean>(false)
15+
const apiLoading = ref<boolean>(false)
1616
const apiError = ref<ApiErrorResponse | null>(null)
1717
const formData = ref<ProfileEditRequest>({
1818
first_name: '',

packages/sprinkle-account/app/schema/requests/profile-settings.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ last_name:
1616
min: 1
1717
max: 30
1818
message: VALIDATE.LENGTH_RANGE
19+
required:
20+
label: "&LAST_NAME"
21+
message: VALIDATE.REQUIRED
1922
locale:
2023
validators:
2124
required:

packages/theme-pink-cupcake/src/components/Pages/Account/FormUserProfile.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function getAvailableLocales(): string[] {
2020
/**
2121
* API - Use the profile edit API.
2222
*/
23-
const { submitProfileEdit, r$, formData } = useUserProfileEditApi()
23+
const { submitProfileEdit, r$, formData, apiLoading } = useUserProfileEditApi()
2424
2525
/**
2626
* Initialize form data with user profile information.
@@ -100,7 +100,11 @@ const submitForm = () => {
100100
</div>
101101

102102
<div class="uk-text-center" uk-margin>
103-
<button class="uk-button uk-button-primary" type="submit" tabindex="4">
103+
<button
104+
class="uk-button uk-button-primary"
105+
:disabled="r$.$error || apiLoading"
106+
type="submit"
107+
tabindex="4">
104108
{{ $t('SAVE') }}
105109
</button>
106110
</div>

0 commit comments

Comments
 (0)