Module: ActionView::Helpers::FormOptionsHelper
- Defined in:
- lib/i18n_plus/state.rb,
lib/i18n_plus/locale.rb,
lib/i18n_plus/country.rb,
lib/i18n_plus/currency.rb,
lib/i18n_plus/language.rb
Instance Method Summary collapse
- #country_options_for_select(selected = nil, *priority_country_codes) ⇒ Object
- #country_select(object, method, priority_country_codes = nil, options = {}, html_options = {}) ⇒ Object
- #currency_options_for_select(selected = nil, *priority_currency_codes) ⇒ Object
- #currency_select(object, method, priority_currency_codes = nil, options = {}, html_options = {}) ⇒ Object
- #language_options_for_select(selected = nil, *priority_language_codes) ⇒ Object
- #language_select(object, method, priority_language_codes = nil, options = {}, html_options = {}) ⇒ Object
- #locale_options_for_select(selected = nil, *priority_locale_codes) ⇒ Object
- #locale_select(object, method, priority_locale_codes = nil, options = {}, html_options = {}) ⇒ Object
- #state_options_for_select(country_code, selected = nil) ⇒ Object
- #state_select(object, method, country_code, options = {}, html_options = {}) ⇒ Object
Instance Method Details
#country_options_for_select(selected = nil, *priority_country_codes) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/i18n_plus/country.rb', line 33 def (selected = nil, *priority_country_codes) html = "".html_safe unless priority_country_codes.empty? priority_countries = priority_country_codes.map { |code| [I18nPlus.country_name(code), code] } unless priority_countries.empty? html += (priority_countries, selected) html += "<option value=\"\" disabled=\"disabled\">----------</option>".html_safe end end all_countries = I18nPlus.countries.map { |code,name| [name, code] }.sort return html + (all_countries, priority_country_codes.include?(selected) ? nil : selected) end |
#country_select(object, method, priority_country_codes = nil, options = {}, html_options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/i18n_plus/country.rb', line 23 def country_select(object, method, priority_country_codes = nil, = {}, = {}) tag = if defined?(ActionView::Helpers::InstanceTag) && ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0 InstanceTag.new(object, method, self, .delete(:object)) else CountrySelect.new(object, method, self, ) end tag.to_country_select_tag(priority_country_codes, , ) end |
#currency_options_for_select(selected = nil, *priority_currency_codes) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/i18n_plus/currency.rb', line 33 def (selected = nil, *priority_currency_codes) html = "".html_safe unless priority_currency_codes.empty? priority_currencies = priority_currency_codes.map { |code| [I18nPlus.currency_name(code), code] } unless priority_currencies.empty? html += (priority_currencies, selected) html += "<option value=\"\" disabled=\"disabled\">----------</option>".html_safe end end all_currencies = I18nPlus.currencies.map { |code,name| [name, code] }.sort return html + (all_currencies, priority_currency_codes.include?(selected) ? nil : selected) end |
#currency_select(object, method, priority_currency_codes = nil, options = {}, html_options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/i18n_plus/currency.rb', line 23 def currency_select(object, method, priority_currency_codes = nil, = {}, = {}) tag = if defined?(ActionView::Helpers::InstanceTag) && ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0 InstanceTag.new(object, method, self, .delete(:object)) else CurrencySelect.new(object, method, self, ) end tag.to_currency_select_tag(priority_currency_codes, , ) end |
#language_options_for_select(selected = nil, *priority_language_codes) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/i18n_plus/language.rb', line 34 def (selected = nil, *priority_language_codes) html = "".html_safe unless priority_language_codes.empty? priority_languages = priority_language_codes.map { |code| [I18nPlus.language_name(code), code] } unless priority_languages.empty? html += (priority_languages, selected) html += "<option value=\"\" disabled=\"disabled\">----------</option>".html_safe end end all_languages = I18nPlus.languages.map { |code,name| [name, code] }.sort return html + (all_languages, priority_language_codes.include?(selected) ? nil : selected) end |
#language_select(object, method, priority_language_codes = nil, options = {}, html_options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/i18n_plus/language.rb', line 23 def language_select(object, method, priority_language_codes = nil, = {}, = {}) tag = if defined?(ActionView::Helpers::InstanceTag) && ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0 InstanceTag.new(object, method, self, .delete(:object)) else LanguageSelect.new(object, method, self, ) end tag.to_language_select_tag(priority_language_codes, , ) end |
#locale_options_for_select(selected = nil, *priority_locale_codes) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/i18n_plus/locale.rb', line 33 def (selected = nil, *priority_locale_codes) html = "".html_safe unless priority_locale_codes.empty? priority_locales = priority_locale_codes.map { |code| [I18nPlus.locale_name(code), code] } unless priority_locales.empty? html += (priority_locales, selected) html += "<option value=\"\" disabled=\"disabled\">----------</option>".html_safe end end all_locales = I18nPlus.locales.map { |code,name| [name, code] }.sort return html + (all_locales, priority_locale_codes.include?(selected) ? nil : selected) end |
#locale_select(object, method, priority_locale_codes = nil, options = {}, html_options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/i18n_plus/locale.rb', line 23 def locale_select(object, method, priority_locale_codes = nil, = {}, = {}) tag = if defined?(ActionView::Helpers::InstanceTag) && ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0 InstanceTag.new(object, method, self, .delete(:object)) else LocaleSelect.new(object, method, self, ) end tag.to_locale_select_tag(priority_locale_codes, , ) end |
#state_options_for_select(country_code, selected = nil) ⇒ Object
33 34 35 36 37 |
# File 'lib/i18n_plus/state.rb', line 33 def (country_code, selected = nil) collection = I18nPlus.states(country_code) = collection.map { |code,name| [name, code] }.sort (, selected) end |
#state_select(object, method, country_code, options = {}, html_options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/i18n_plus/state.rb', line 23 def state_select(object, method, country_code, = {}, = {}) tag = if defined?(ActionView::Helpers::InstanceTag) && ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0 InstanceTag.new(object, method, self, .delete(:object)) else StateSelect.new(object, method, self, ) end tag.to_state_select_tag(country_code, , ) end |