From 96417592a31e311f70cda190e66513ad12f28e9e Mon Sep 17 00:00:00 2001 From: Jan Cernik <66427541+jancernik@users.noreply.github.com> Date: Thu, 12 Dec 2024 18:45:28 -0300 Subject: [PATCH] FIX: Show validation error on confirmation user fields (#30232) * FIX: Show validation error on confirmation user fields * test --- .../discourse/app/components/user-fields/confirm.hbs | 4 ++++ .../discourse/app/mixins/user-fields-validation.js | 6 +++++- .../tests/acceptance/create-account-user-fields-test.js | 4 ++++ config/locales/client.en.yml | 3 ++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/user-fields/confirm.hbs b/app/assets/javascripts/discourse/app/components/user-fields/confirm.hbs index 2640fa7840d..9737e1fac34 100644 --- a/app/assets/javascripts/discourse/app/components/user-fields/confirm.hbs +++ b/app/assets/javascripts/discourse/app/components/user-fields/confirm.hbs @@ -19,4 +19,8 @@ >*{{/if}}{{/unless}} + \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/mixins/user-fields-validation.js b/app/assets/javascripts/discourse/app/mixins/user-fields-validation.js index 83a0d3278a2..b9a7e0693ad 100644 --- a/app/assets/javascripts/discourse/app/mixins/user-fields-validation.js +++ b/app/assets/javascripts/discourse/app/mixins/user-fields-validation.js @@ -36,9 +36,13 @@ export default Mixin.create({ userField.field.required && (!userField.value || isEmpty(userField.value)) ) { + const reasonKey = + userField.field.field_type === "confirm" + ? "user_fields.required_checkbox" + : "user_fields.required"; validation = EmberObject.create({ failed: true, - reason: i18n("user_fields.required", { + reason: i18n(reasonKey, { name: userField.field.name, }), element: userField.field.element, diff --git a/app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js b/app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js index ff6095a81dc..1548948567c 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js @@ -104,6 +104,10 @@ acceptance("Create Account - User Fields", function (needs) { .dom(".user-field-what-is-your-pets-name .tip.bad") .exists("shows required field error"); + assert + .dom(".user-field-ive-read-the-terms-of-service .tip.bad") + .exists("shows required field error"); + assert .dom(".user-field-whats-your-dad-like .tip.bad") .exists("shows same as password error"); diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 8075ba8c99a..c8d52545966 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1212,7 +1212,8 @@ en: user_fields: none: "(select an option)" required: 'Please enter a value for "%{name}"' - same_as_password: "Your password should not be repeated in other fields." + required_checkbox: 'The field "%{name}" is required' + same_as_password: "Your password should not be repeated in other fields" optional: (optional) user: