Optional select in Classic Universal Login additionalSignupFields?

Hi Auth0 team, in Classic Universal Login additionalSignupFields, is there any way to make a select field optional? I see that the validator on text fields can make them optional, but I can’t figure out how to do it for a select.

Hi @sinclair.kinch,

Welcome to the Auth0 Community!

Yes! If you require the additionalSignUpFields to be optional, you will need to update the validator for the field to always return true.

See below of an example.

additionalSignUpFields: [{
  name: "Company",
  placeholder: "Company",
  icon: "https://example.com/assests/address_icon.png",
  validator: function(company) {
    return {
      valid: true
    };
  }
}]

I hope this helps!

Thanks,
Rueben

Hi @rueben.tiow, thanks for your response. I’m asking about a field with "type": "select". It appears not to accept a validator, so I’m wondering if there’s a way to make a select field optional.

Hi @sinclair.kinch,

Thank you for your reply and clarification.

Ah, yes, I missed an important detail that it was the select field and not a text field. My apologies for that.

In this situation, unfortunately, the select field is non-optional. When the user tries to sign up, there will already be a default value selected. Let’s take a look at this example:

  additionalSignUpFields: [{
    type: "select",
    name: "location",
    placeholder: "choose your location",
    options: [
      {value: "us", label: "United States"},
      {value: "fr", label: "France"},
      {value: "ar", label: "Argentina"}
    ],
    // The following properties are optional
    icon: "https://example.com/assests/location_icon.png",
    prefill: "us"
  }]

In the code above, the default value selected would be “United States,” which would not require the user to select a choice.

As a workaround, you could include an additional “None” value as the default value so that it mimics an optional select field.

I hope this helps!

Thanks,
Rueben

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.