Replace the label hack in grouped select forms by a decent optgroup

This commit is contained in:
Paul van Tilburg 2013-06-26 20:46:27 +02:00
parent 43e862d5de
commit 62dfd04776
1 changed files with 7 additions and 6 deletions

View File

@ -2483,12 +2483,13 @@ module StopTime::Views
html_options.merge!(:name => name, :id => name)
select(html_options) do
opts.keys.sort.each do |key|
option("#{key}", {:disabled => true})
opts[key].sort_by { |o| o.last }.each do |opt_val, opt_str|
if @input[name] == opt_val
option(opt_str, {:value => opt_val, :selected => true})
else
option(opt_str, {:value => opt_val})
optgroup :label => key do
opts[key].sort_by { |o| o.last }.each do |opt_val, opt_str|
if @input[name] == opt_val
option(opt_str, {:value => opt_val, :selected => true})
else
option(opt_str, {:value => opt_val})
end
end
end
end