lib/country-select.rb
# Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
Return select and option tags for the given object and method using country_options_for_select to generate the list of option tags .
def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
        choices = COUNTRIES.dup
        if priority_countries
          if (unlisted = priority_countries - choices).any?
            raise RuntimeError.new("Supplied priority countries are not in the main list: #{unlisted}")
          end
          sep = "-------------"
          choices.unshift(sep)
          choices.unshift(*priority_countries)
          disabled = Array.wrap(options.fetch(:disabled, []))
          disabled |= [sep]
          options[:disabled] = disabled
        end
        Tags::Select.new(object, method, self, choices, options, html_options).render
      end
def country_select ( object , method , priority_countries = nil , options = { } , html_options = { } ) choices = COUNTRIES . dup if priority_countries if ( unlisted = priority_countries - choices ) . any? raise RuntimeError . new ( "Supplied priority countries are not in the main list: #{unlisted}" ) end sep = "-------------" choices . unshift ( sep ) choices . unshift ( * priority_countries ) disabled = Array . wrap ( options . fetch ( :disabled , [ ] ) ) disabled |= [ sep ] options [ :disabled ] = disabled end Tags :: Select . new ( object , method , self , choices , options , html_options ) . render end
Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
Return select and option tags for the given object and method using country_options_for_select to generate the list of option tags .
object
method
priority_countries
options
html_options