public Method

FormOptionsHelper.country_options_for_select(selected = nil, priority_countries = nil)

Returns a string of option tags for pretty much any country in the world. Supply a country name as selected to have it marked as the selected option tag. You can also supply an array of countries as priority_countries, so that they will be listed above the rest of the (long) list.

NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag.

Source Code

# File action_view/helpers/form_options_helper.rb, line 258
def country_options_for_select(selected = nil, priority_countries = nil)
  country_options = ""

  if priority_countries
    country_options += options_for_select(priority_countries, selected)
    country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
  end

  return country_options + options_for_select(COUNTRIES, selected)
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.