Select field as multiple selector

Hi All.

I was wondering if there is an option to allow multiple selections in a single select field and storage it as an array in the user_metadata space? Or could be a checkboxes field an alternative?

var options = {
  additionalSignUpFields: [{
    type: "select",
    name: "preferences",
    placeholder: "My Preferences",
    options: [
      {value: "a", label: "Preference Yellow"},
      {value: "b", label: "Preference Red"},
      {value: "c", label: "Preference Green"},
      {value: "d", label: "Preference Purple"},
      {value: "e", label: "Preference Black"}
    ],
    // The following properties are optional
    icon: "https://example.com/assests/location_icon.png",
    prefill: "us"
  }]
}

And save it as:

{
    "user_metadata": {
        "preferences": [
            {
                "value": "a" // Yellow
            },
            {
                "value": "d" // Purple
            }
        ]
    }
}

Hello, @hgiraldo - welcome to the Auth0 Community!

Unfortunately, not. The best way to achieve this would be to use multiple Checkbox Fields, and maybe you can edit the metadata with a Rule? You could call them all with the preference_ prefix, and then use the Rule to modify any user_metadata values that have multiple preference_ fields into just one. Of course, this would require some extra coding.

1 Like

Thanks Jose, understood.

Last thing, Can a Markup be added before an additionalSignUpFields is printed? I would like to add an h2 (As group title) tag before the checkboxes or it must be added by js?

Hey @hgiraldo,

This would have to be added by Javascript - you would have to edit Lock in order to display that text with that tag.

1 Like

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