-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
Add a new select_prompt method #1027
Labels
Comments
Thank you for creating this! I think both options should be available. The one that removes the option if a value was selected is nice when select a blank value is invalid, so it should only show “Select your option” for brand new records.
…On Mar 5, 2020, 2:07 PM -0500, Jeremy Woertink ***@***.***>, wrote:
If you're using select_tag and rending all your options, there's no easy way to currently set your prompt. It would be neat to have a select_prompt method so we don't just bloat the current options_for_select with options.
select(op.opts) do
select_prompt("Select your option")
options_for_select(op.opts, my_options)
end
My thought is this method would only generate:
<option value="">Select your option</option>
If your prompt option is first, then it will display that, unless you have a selected option. The selected option would get set from your options_for_select, and then it would default to that.
Another way could be to pass in the attribute so you could not render the field if there's a value, but then you'd never be able to "unselect" your value....
select_prompt(op.opts, "Select your option")
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
ah! Yeah, I guess that's true too. You might not want someone to select a blank value if the record already exists. Good thinking! |
This would be nice. I frequently use multiple This took me some time to figure out initially because I was expecting a options_for_select @save_user.manager_id, [{"", ""}]
options_for_select @save_user.manager_id, @manager_options |
jwoertink
added a commit
that referenced
this issue
Apr 27, 2020
5 tasks
jwoertink
added a commit
that referenced
this issue
Apr 30, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you're using
select_tag
and rending all your options, there's no easy way to currently set your prompt. It would be neat to have aselect_prompt
method so we don't just bloat the currentoptions_for_select
with options.My thought is this method would only generate:
If your prompt option is first, then it will display that, unless you have a selected option. The selected option would get set from your
options_for_select
, and then it would default to that.Another way could be to pass in the attribute so you could not render the field if there's a value, but then you'd never be able to "unselect" your value....
select_prompt(op.opts, "Select your option")
The text was updated successfully, but these errors were encountered: