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
Should select show a prompt when its attribute is false? #51602
Comments
Maybe, but this is a change in behavior so it needs to be well justified. Can you expand why the current behavior doesn't work for you giving a real example? |
Rafael, I'm just finding that the prompt persists even when a boolean option has been selected and saved. I expected the prompt to disappear as it's no longer needed because the user understands the choices. No prompt also makes the size of this select much more compact and neater. |
Makes sense to me. Do you want to open a pull request? |
This behavior has existed forever, and I believe it's correct. In the case of a boolean column, as an example, you may want to force the user to choose the truthy value to proceed. A checkbox is probably more appropriate but some people prefer to use select. What I've done in the past is simply |
Thank you Justin. In my case either a select or two mutually-exclusive buttons scripted to a hidden radio, checkbox, or field is most appropriate. If this change won't proceed, I'll take your suggestion and change from
to
|
Justin, what's your argument for the current behaviour being correct (rather than just traditional). Is there a circumstance where the changed behaviour would be wrong or unexpected (PLOS-wise)? |
I can't think of a circumstance where it would be wrong, but you do remove the ability to have |
I was curious and looked at other frameworks and libraries. For the ones that actually have a prompt option, they allow/require full control over whether it's utilized or not (equivalent in Rails would be removing |
At the moment the attribute select helper adds the empty prompt option if the attribute is blank. However
blank?
istrue
forfalse
, meaning that the prompt will still be shown if a boolean attribute has been set to the valid value offalse
rather than its initialnull
.Should the ActionView line linked above instead be:
if value != false && value.blank? && options[:prompt]
?The text was updated successfully, but these errors were encountered: