Module: ActionView::Helpers::FormOptionsHelper
- Defined in:
- lib/localized_country_select.rb
Instance Method Summary collapse
-
#country_options_for_select(selected = nil, priority_countries = nil, options = {}) ⇒ Object
Returns a string of option tags for countries according to locale.
-
#country_select(object, method, priority_countries = nil, options = {}, html_options = {}) ⇒ Object
Return select and option tags for the given object and method, using
localized_country_options_for_select
to generate the list of option tags. -
#country_select_tag(name, selected_value = nil, priority_countries = nil, html_options = {}) ⇒ Object
Return “named” select and option tags according to given arguments.
Instance Method Details
#country_options_for_select(selected = nil, priority_countries = nil, options = {}) ⇒ Object
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
77 78 79 80 81 82 83 84 |
# File 'lib/localized_country_select.rb', line 77 def (selected = nil, priority_countries = nil,={}) = "" if priority_countries += (LocalizedCountrySelect::priority_countries_array(priority_countries,), selected) += "<option value=\"\" disabled=\"disabled\">-------------</option>\n" end return + (LocalizedCountrySelect::localized_countries_array(), selected) end |
#country_select(object, method, priority_countries = nil, options = {}, html_options = {}) ⇒ Object
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
61 62 63 64 |
# File 'lib/localized_country_select.rb', line 61 def country_select(object, method, priority_countries = nil, = {}, = {}) InstanceTag.new(object, method, self, .delete(:object)). to_localized_country_select_tag(priority_countries, , ) end |
#country_select_tag(name, selected_value = nil, priority_countries = nil, html_options = {}) ⇒ Object
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
70 71 72 |
# File 'lib/localized_country_select.rb', line 70 def country_select_tag(name, selected_value = nil, priority_countries = nil, = {}) select_tag name.to_sym, (selected_value, priority_countries), .stringify_keys end |