Module: ActionView::Helpers::FormOptionsHelper
- Defined in:
- lib/lola/helpers.rb
Instance Method Summary collapse
-
#language_options_for_select(selected = nil, *priority_language_codes) ⇒ Object
Returns a string of option tags for pretty much any language in the world.
-
#language_select(object, method, priority_languages = nil, options = {}, html_options = {}) ⇒ Object
Return select and option tags for the given object and method, using language_options_for_select to generate the list of option tags.
Instance Method Details
#language_options_for_select(selected = nil, *priority_language_codes) ⇒ Object
Returns a string of option tags for pretty much any language in the world. Supply a language name as selected
to have it marked as the selected option tag. You can also supply a list of language codes as additional parameters, so that they will be listed above the rest of the (long) list.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/lola/helpers.rb', line 12 def (selected = nil, *priority_language_codes) = "" unless priority_language_codes.empty? priority_languages = Lola::languages.select do |pair| name, code = pair priority_language_codes.include?(code) end unless priority_languages.empty? += (priority_languages, selected) += "\n<option value=\"\" disabled=\"disabled\">-------------</option>\n" end end = + (Lola.languages, priority_language_codes.include?(selected) ? nil : selected) return .html_safe end |
#language_select(object, method, priority_languages = nil, options = {}, html_options = {}) ⇒ Object
Return select and option tags for the given object and method, using language_options_for_select to generate the list of option tags.
5 6 7 |
# File 'lib/lola/helpers.rb', line 5 def language_select(object, method, priority_languages = nil, = {}, = {}) InstanceTag.new(object, method, self, .delete(:object)).to_language_select_tag(priority_languages, , ) end |