Skip to content

Using remix-validated-form with multi select inputs (e.g., react-select) #80

Answered by airjp73
zayenz asked this question in Q&A
Discussion options

You must be logged in to vote

There isn't really anything special you need to do for this. For a regular select element, you can use getInputProps form useField like you normally would.

<select {...getInputProps({ multiple: true })}>
  <option value="myOption1">My Option 1</option>
  <option value="myOption2">My Option 2</option>
</select>

react-select should also be fine. It takes a name prop so you don't even need a hidden input.

<ReactSelect
  {...getIpnutProps({
    multi: true,
    options: [
      { label: 'My Option 1', value: 'myOption1' },
      { label: 'My Option 2', value: 'myOption2' },
    ]
  })}
/>

If you have a controlled component that doesn't have an actual input, then you'll need to take the value …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@zayenz
Comment options

Answer selected by zayenz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants