Skip to content

Form.Select how to use custom array options #2281

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

Closed
eranabir opened this issue Nov 2, 2017 · 2 comments
Closed

Form.Select how to use custom array options #2281

eranabir opened this issue Nov 2, 2017 · 2 comments

Comments

@eranabir
Copy link

eranabir commented Nov 2, 2017

From.Select needs to have a specific array like that :

const options = [
 { key: 'm', text: 'Male', value: 'male' },
 { key: 'f', text: 'Female', value: 'female' },
]

and using it like that :

<Form.Field control={Select} label='Gender' options={options} placeholder='Gender' />

if i want to use other array with custom keys and values like that for example :

const options = [
 { date: 'somedate', title: 'sometitle', },
 { date: 'somedate', title: 'sometitle', },
]

i am getting an error about using wrong props

my question is how can i use my own array with this Select Component thanks !

@brianespinosa
Copy link
Member

@ElectroZed Select is a sugar for a Dropdown with the selection prop added to it. There are lots of examples on how to use the options prop correctly there. I'd recommend starting here: https://react.semantic-ui.com/modules/dropdown#dropdown-example-multiple-selection

@levithomason
Copy link
Member

Your array must match the shape the component needs. You should map() your array into the proper shape before passing it. Take a look at the link provided above.

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

3 participants