module ActionView::Helpers::FormOptionsHelper
Public Instance Methods
Returns a string of option tags for countries according to locale. Supply the country code in upper-case ('US', 'DE') as selected
to have it marked as the selected option tag. Country codes listed as an array of symbols in priority_countries
argument will be listed first
# File lib/localized_country_select.rb, line 78 def localized_country_options_for_select(selected = nil, priority_countries = nil, options={}) country_options = "".html_safe if priority_countries country_options += options_for_select(LocalizedCountrySelect::priority_countries_array(priority_countries, options), selected) country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n".html_safe return country_options + options_for_select(LocalizedCountrySelect::localized_countries_array(options) - LocalizedCountrySelect::priority_countries_array(priority_countries, options), selected) else return country_options + options_for_select(LocalizedCountrySelect::localized_countries_array(options), selected) end end
Return select and option tags for the given object and method, using localized_country_options_for_select
to generate the list of option tags. Uses country code, not name as option value
. Country codes listed as an array of symbols in priority_countries
argument will be listed first TODO : Implement pseudo-named args with a hash, not the “somebody said PHP?” multiple args sillines
# File lib/localized_country_select.rb, line 59 def localized_country_select(object, method, priority_countries = nil, options = {}, html_options = {}) tag = CountrySelect.new(object, method, self, options) tag.to_localized_country_select_tag(priority_countries, options, html_options) end
Return “named” select and option tags according to given arguments. Use selected_value
for setting initial value It behaves likes older object-binded brother localized_country_select
otherwise TODO : Implement pseudo-named args with a hash, not the “somebody said PHP?” multiple args sillines
# File lib/localized_country_select.rb, line 70 def localized_country_select_tag(name, selected_value = nil, priority_countries = nil, html_options = {}) select_tag name.to_sym, localized_country_options_for_select(selected_value, priority_countries).html_safe, html_options.stringify_keys end