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

Feature Request: Custom options for select field #78

Closed
RSchwan opened this issue Jul 20, 2016 · 9 comments
Closed

Feature Request: Custom options for select field #78

RSchwan opened this issue Jul 20, 2016 · 9 comments
Assignees
Labels
Type: Feature New features and feature requests

Comments

@RSchwan
Copy link
Contributor

RSchwan commented Jul 20, 2016

See http://autoform.meteorapp.com/select
This would allow dynamic select fields

@macrozone
Copy link
Contributor

You can pass allowedValues as property to the select-field and add a transform-function that returns a label for each value to achieve the same thing.

In my case i created custom form elements where i declare an options-property, which is an array of {key, value} like in autoform because that is much easier to implement than allowedValues and transform.

@RSchwan
Copy link
Contributor Author

RSchwan commented Jul 20, 2016

I see your point. But wouldn't it be easier and more simple to bake it directly into the library?

@radekmie radekmie added the Type: Feature New features and feature requests label Jul 20, 2016
@radekmie radekmie self-assigned this Jul 20, 2016
@radekmie
Copy link
Contributor

It's already done. You can read more in #23, but the API is the same - you can pass options property (or pass it in uniforms object in your schema). It can be either an object or an array (or a function, that returns it). Basically it overrides allowedValues and transform. Source.

@RSchwan
Copy link
Contributor Author

RSchwan commented Jul 20, 2016

The options property works great!
The only thing I wonder is if there is a way to set a default label. If the field is optional there should be an option for deselection the field.
I tried to add something like this to the options array: { label: 'None', value: undefined } but for the validator there is still a empty string selected.

@radekmie
Copy link
Contributor

Use placeholder.

@RSchwan
Copy link
Contributor Author

RSchwan commented Jul 20, 2016

For the validator there is still a empty string and so my validation fails.
And the other thing is that you can't reselect the placeholder.
Autoform for example has a firstOption property.

@radekmie
Copy link
Contributor

Well, I have to think about it. Also, it would be nice, @RSchwan, if you could describe your desired API (and behaviour) here.

@RSchwan
Copy link
Contributor Author

RSchwan commented Jul 20, 2016

Ok I figured out where my problem was. I didn't know that custom validations are fired although I you have optional set to true.

@radekmie
Copy link
Contributor

It's good to know it, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New features and feature requests
Projects
Archived in project
Development

No branches or pull requests

3 participants