Skip to content

Commit

Permalink
fix: form submission when country is not requried
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
ghassanmas committed Nov 2, 2023
1 parent 397c237 commit 446d0ef
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/register/data/utils.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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']);
Expand Down

0 comments on commit 446d0ef

Please sign in to comment.