Module: ActionView::Helpers::FormOptionsHelper

Defined in:
lib/countryselect0r/base.rb

Instance Method Summary collapse

Instance Method Details

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



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/countryselect0r/base.rb', line 20

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

  if priority_countries && priority_countries.is_a?(Array)
    # +_+ #
    priority_countries.each do |pc|
      # +_+ #
      country_options += options_for_select({ Iso3166.localize(pc) => pc }, selected)
    end
    #country_options += options_for_select(priority_countries, selected)
    country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
    selected=nil if priority_countries.include?(selected)
  end

  countries = Iso3166.codes.map { |code|
    [Iso3166.localize(code), code]
  }

  country_options = country_options.html_safe if country_options.respond_to?(:html_safe)

  return country_options + options_for_select(countries, selected)
end

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



16
17
18
# File 'lib/countryselect0r/base.rb', line 16

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