Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to optional "select" fields #783

Open
nickfla1-mxm opened this issue Jan 10, 2025 · 0 comments
Open

Add support to optional "select" fields #783

nickfla1-mxm opened this issue Jan 10, 2025 · 0 comments

Comments

@nickfla1-mxm
Copy link

Currently the select field only support String, Number or Boolean types but in the case of optional fields forcing the user to select a value can be counter-intuitive.

Given the following example:

fields: {
  mySelect: {
    type: 'select',
    options: [
      { label: 'A', value: 'a' },
      { label: 'B', value: 'b' },
    ]
  }
}

if mySelect represents an optional value we could either

fields: {
  mySelect: {
    type: 'select',
    options: [
      { label: '', value: undefined }, // allow having `undefined` or `null` values
      { label: 'A', value: 'a' },
      { label: 'B', value: 'b' },
    ]
  }
}

or (cleaner in my opinion)

fields: {
  mySelect: {
    type: 'select',
    optional: true, // required: false alternatively
    options: [
      { label: 'A', value: 'a' },
      { label: 'B', value: 'b' },
    ]
  }
}

I am available to contribute directly to this feature if approved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant