method
to_select_tag
rails latest stable - Class:
ActionView::Helpers::InstanceTag
to_select_tag(choices, options, html_options)public
No documentation available.
# File actionpack/lib/action_view/helpers/form_options_helper.rb, line 579
def to_select_tag(choices, options, html_options)
selected_value = options.has_key?(:selected) ? options[:selected] : value(object)
choices = choices.to_a if choices.is_a?(Range)
# Grouped choices look like this:
#
# [nil, []]
# { nil => [] }
#
if !choices.empty? && choices.first.respond_to?(:last) && Array === choices.first.last
option_tags = grouped_options_for_select(choices, :selected => selected_value, :disabled => options[:disabled])
else
option_tags = options_for_select(choices, :selected => selected_value, :disabled => options[:disabled])
end
select_content_tag(option_tags, options, html_options)
end