-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Support include_blank option for select form helper #54
Conversation
8bd91dd
to
a1dc7ca
Compare
@davydovanton have you ever thought about the default option could have different messages? In Rails 4, there is |
@davydovanton thanks for your PR! I prefer |
@joneslee85 @AlfonsoUceda thanks for feedback 👍 |
# <%= | ||
# # ... | ||
# values = Hash['it' => 'Italy', 'us' => 'United States'] | ||
# select :stores, values, options: { include_blank: true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick,
{ include_blank: true}
#to
{include_blank: true}
@davydovanton PING 😉 |
|
||
super(attributes) do | ||
option(prompt_value.is_a?(String) ? prompt_value : '') if prompt_value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this solution, but when prompt_value
is true
prompt_value.to_s
returns 'true'
string. If you have better solution I'll happy to use it 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davydovanton I think that prompt:
should be used only with strings. For instance
<%=
values = Hash['it' => 'Italy', 'us' => 'United States']
select :stores, values, options: {prompt: 'Select a City'}
%>
or
<%=
values = Hash['it' => 'Italy', 'us' => 'United States']
select :stores, values, options: {prompt: ''}
%>
but not..
<%=
values = Hash['it' => 'Italy', 'us' => 'United States']
select :stores, values, options: {prompt: true}
%>
Does it makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, I think you're right. thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
@jodosha pong :) |
ce89bc8
to
84bc9f9
Compare
attributes = { name: _input_name(name), id: _input_id(name) }.merge(attributes) | ||
options = attributes.delete(:options) { {} } | ||
attributes = { name: _input_name(name), id: _input_id(name) }.merge(attributes) | ||
blank_value = options.delete(:include_blank) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davydovanton include_blank: true
overlaps with prompt: ""
. What if we remove the first? 😉
@davydovanton I've just merged this, by removing the |
thanks! |
No description provided.