thisbeyond / solid-select

The Select component for Solid.
https://solid-select.com
MIT License
172 stars 18 forks source link

Option Key and Value #61

Closed robodna closed 2 months ago

robodna commented 2 months ago

My options are an array of objects with "id" and "name" properties. How do I specify the key and value fields?

Thanks

martinpengellyphillips commented 2 months ago

Pass your array in as the options for Select and then specify a custom format function to pick the field (e.g. name) you want to display.

If you are using createOptions helper, you can specify key instead for the basic case.

Note that solid-select will pass through your full objects as the value. For example, onChange will receive the full object for you to use.

robodna commented 2 months ago

Ok, that worked, thanks.