Module: ActionView::Helpers::FormOptionsHelper

Defined in:
lib/countries/select_helper.rb

Instance Method Summary collapse

Instance Method Details

#country_options_for_select(selected = nil, priority_countries = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/countries/select_helper.rb', line 10

def country_options_for_select(selected = nil, priority_countries = nil)
  country_options = "".html_safe

  if priority_countries
    priority_countries = [*priority_countries].map {|x| [x,ISO3166::Country::NameIndex[x]] }
    country_options += options_for_select(priority_countries, selected)
    country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n".html_safe
  end

  return country_options + options_for_select(ISO3166::Country::Names, selected)
end

#country_select(object, method, priority_countries = nil, options = {}, html_options = {}) ⇒ Object



6
7
8
# File 'lib/countries/select_helper.rb', line 6

def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
  InstanceTag.new(object, method, self, options.delete(:object)).to_country_select_tag(priority_countries, options, html_options)
end