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

Rails-style options for select #1436

Merged
merged 3 commits into from Oct 8, 2013

Conversation

Projects
None yet
2 participants
@ujifgc
Member

ujifgc commented Oct 8, 2013

ref #872

opts = {
  "Friends" => ["Yoda",["Obiwan",2,:magister=>'no'],:lame=>'yes'],
  "Enemies" => [["Palpatine","Palpatine",:scary=>'yes',:old=>'yes'],["Darth Vader",3,:disabled=>true]]
}
actual_html = select_tag( 'name', :grouped_options => opts, :disabled_options => [2], :selected => ['Yoda'] )

=>

<select name="name">
<optgroup label="Friends" lame="yes">
<option value="Yoda" selected="selected">Yoda</option>
<option value="2" magister="no" disabled="disabled">Obiwan</option>
</optgroup>
<optgroup label="Enemies">
<option value="Palpatine" scary="yes" old="yes">Palpatine</option>
<option value="3" disabled="disabled">Darth Vader</option>
</optgroup>
</select>

If additional API is acceptable, we can close #872

Also I would like to drop confusing API with slipping booleans into array of options to disable them like this:

opts = {
        "Friends" => ["Yoda",["Obiwan",2,true]] # I'm confused, my head is spinning
@namusyaka

This comment has been minimized.

Show comment
Hide comment
@namusyaka

namusyaka Oct 8, 2013

Member

Awesome!

Member

namusyaka commented Oct 8, 2013

Awesome!

namusyaka added a commit that referenced this pull request Oct 8, 2013

Merge pull request #1436 from padrino/rails-style-select
Rails-style options for select, closes #872

@namusyaka namusyaka merged commit c7dd679 into master Oct 8, 2013

1 check failed

default The Travis CI build could not complete due to an error
Details

@ujifgc ujifgc deleted the rails-style-select branch Oct 8, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment