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

Remove prompt from boolean select field #17

Merged
merged 1 commit into from
Aug 12, 2016
Merged

Conversation

darinwilson
Copy link
Contributor

@darinwilson darinwilson commented Aug 11, 2016

This removes the "Choose one:" prompt when generating a boolean select field. This fixes issue #11.

If you supply a prompt option to phoenix_html's select function, it always adds the prompt as an option with an empty value. This doesn't really make sense for a boolean, which should only be true or false, never blank.

@yulianglukhenko correctly points out that placeholders for select fields should be disabled, rather than having a blank value. That forces the user to make a selection which, for an optional field, is not what you want. Ideally, select would also take a required option that would either force the user to select an option, or allow the blank value. That would make a nice PR for phoenix_html.

@yulolimum
Copy link
Contributor

If this specific select is a boolean, wouldn't it be safe to just default to false? That would be the same as a nil for when you're doing logic, but would also pass the changeset validations on update.. @darinwilson

@zberkom
Copy link
Contributor

zberkom commented Aug 12, 2016

Looks good!

@darinwilson
Copy link
Contributor Author

@yulianglukhenko I'm not sure that false is necessarily any safer than true - it really depends on context. I'm inclined to err on the side of simplicity at this point and leave it as is. And since this is just a generator, the user can customize as they see fit.

@yulolimum
Copy link
Contributor

Agreed - :)

@yulolimum yulolimum merged commit a10674c into master Aug 12, 2016
@danielberkompas danielberkompas deleted the boolean-field-options branch August 12, 2016 16:36
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

Successfully merging this pull request may close these issues.

3 participants