mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
refactor grouped_options_for_select
This commit is contained in:
parent
eff507f44d
commit
421025f18d
1 changed files with 5 additions and 5 deletions
|
@ -472,16 +472,16 @@ module ActionView
|
|||
# <b>Note:</b> Only the <tt><optgroup></tt> and <tt><option></tt> tags are returned, so you still have to
|
||||
# wrap the output in an appropriate <tt><select></tt> tag.
|
||||
def grouped_options_for_select(grouped_options, selected_key = nil, prompt = nil)
|
||||
body = ''
|
||||
body << content_tag(:option, prompt, { :value => "" }, true) if prompt
|
||||
body = "".html_safe
|
||||
body.safe_concat content_tag(:option, prompt, :value => "") if prompt
|
||||
|
||||
grouped_options = grouped_options.sort if grouped_options.is_a?(Hash)
|
||||
|
||||
grouped_options.each do |group|
|
||||
body << content_tag(:optgroup, options_for_select(group[1], selected_key), :label => group[0])
|
||||
grouped_options.each do |label, container|
|
||||
body.safe_concat content_tag(:optgroup, options_for_select(container, selected_key), :label => label)
|
||||
end
|
||||
|
||||
body.html_safe
|
||||
body
|
||||
end
|
||||
|
||||
# Returns a string of option tags for pretty much any time zone in the
|
||||
|
|
Loading…
Reference in a new issue