class ActionView::Helpers::Tags::Base

Public Instance Methods

to_country_select_tag(countries, options = {}, html_options = {}) click to toggle source
# File lib/core_extensions/action_view/helpers/form_options_helper.rb, line 69
def to_country_select_tag(countries, options = {}, html_options = {})
  html_options = html_options.stringify_keys
  add_default_name_and_id(html_options)
  options[:include_blank] ||= true unless options[:prompt] || select_not_required?(html_options)

  value = options[:selected] ? options[:selected] : value(object)
  priority_regions = options[:priority] || []
  opts = add_options(country_options_for_select(countries, value, :priority => priority_regions), options, value)
  select = content_tag("select", opts, html_options)
  if html_options["multiple"] && options.fetch(:include_hidden, true)
    tag("input", :disabled => html_options["disabled"], :name => html_options["name"], :type => "hidden", :value => "") + select
  else
    select
  end
end