From db4eeac26668e2f80c7654ba9210c300fe76c7a5 Mon Sep 17 00:00:00 2001 From: Ghassan Maslamani Date: Mon, 13 Nov 2023 18:14:34 +0100 Subject: [PATCH] fix: form submission when country is not requried (#1099) When country is not required to submit, the displayValue check will always return true. This fixes it by only check it if it's needed through the config `SHOW_CONFIGURABLE_EDX_FIELDS` This issue might has been discoverd at edx.org becuase edx.org requires the Country to be filled when creating an account, however this is not the case for Open edX by default, hence the issue reported below Ref: openedx/wg-build-test-release/issues/318 --- src/register/data/utils.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/register/data/utils.js b/src/register/data/utils.js index 810360877d..ca060512be 100644 --- a/src/register/data/utils.js +++ b/src/register/data/utils.js @@ -1,4 +1,4 @@ -import { snakeCaseObject } from '@edx/frontend-platform'; +import { getConfig, snakeCaseObject } from '@edx/frontend-platform'; import { LETTER_REGEX, NUMBER_REGEX } from '../../data/constants'; import messages from '../messages'; @@ -44,11 +44,12 @@ export const isFormValid = ( } }); - if (!configurableFormFields?.country?.displayValue) { - fieldErrors.country = formatMessage(messages['empty.country.field.error']); - isValid = false; + if (getConfig().SHOW_CONFIGURABLE_EDX_FIELDS) { + if (!configurableFormFields?.country?.displayValue) { + fieldErrors.country = formatMessage(messages['empty.country.field.error']); + isValid = false; + } } - Object.keys(fieldDescriptions).forEach(key => { if (key === 'country' && !configurableFormFields.country.displayValue) { fieldErrors[key] = formatMessage(messages['empty.country.field.error']);