Module: ActionView::Helpers::FormOptionsHelper
- Defined in:
- lib/localized_language_select.rb
Instance Method Summary collapse
-
#localized_language_options_for_select(selected = nil, priority_languages = nil, options = {}) ⇒ Object
Returns a string of option tags for languages according to locale.
-
#localized_language_select(object, method, priority_languages = nil, options = {}, html_options = {}) ⇒ Object
Return select and option tags for the given object and method, using
localized_language_options_for_select
to generate the list of option tags. -
#localized_language_select_tag(name, selected_value = nil, priority_languages = nil, html_options = {}) ⇒ Object
Return “named” select and option tags according to given arguments.
Instance Method Details
#localized_language_options_for_select(selected = nil, priority_languages = nil, options = {}) ⇒ Object
Returns a string of option tags for languages according to locale. Supply the language code in lower-case (‘en’, ‘de’) as selected
to have it marked as the selected option tag. Language codes listed as an array of symbols in priority_languages
argument will be listed first
85 86 87 88 89 90 91 92 |
# File 'lib/localized_language_select.rb', line 85 def (selected = nil, priority_languages = nil, = {}) = "" if priority_languages += (LocalizedLanguageSelect::priority_languages_array(priority_languages), selected) += "<option value=\"\" disabled=\"disabled\">-------------</option>\n" end return + (LocalizedLanguageSelect::localized_languages_array(), selected) end |
#localized_language_select(object, method, priority_languages = nil, options = {}, html_options = {}) ⇒ Object
Return select and option tags for the given object and method, using localized_language_options_for_select
to generate the list of option tags. Uses language code, not name as option value
. Language codes listed as an array of symbols in priority_languages
argument will be listed first TODO : Implement pseudo-named args with a hash, not the “somebody said PHP?” multiple args sillines
67 68 69 70 |
# File 'lib/localized_language_select.rb', line 67 def localized_language_select(object, method, priority_languages = nil, = {}, = {}) InstanceTag.new(object, method, self, .delete(:object)). to_localized_language_select_tag(priority_languages, , ) end |
#localized_language_select_tag(name, selected_value = nil, priority_languages = 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_language_select
otherwise TODO : Implement pseudo-named args with a hash, not the “somebody said PHP?” multiple args sillines
76 77 78 79 80 |
# File 'lib/localized_language_select.rb', line 76 def localized_language_select_tag(name, selected_value = nil, priority_languages = nil, = {}) content_tag :select, (selected_value, priority_languages), { "name" => name, "id" => name }.update(.stringify_keys) end |