Module: ActionView::Helpers::FormOptionsHelper

Included in:
InstanceTag
Defined in:
lib/config/initializers/intl_select.rb,
lib/config/initializers/intl_select.rb

Instance Method Summary collapse

Instance Method Details

#intl_options_for_select(container, selected = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/config/initializers/intl_select.rb', line 11

def intl_options_for_select(container, selected = nil)
  container = container.to_a if Hash === container

  options_for_select = container.inject([]) do |options, element|
    text, value = option_text_and_value(element)
    selected_attribute = ' selected="selected"' if option_value_selected?(value, selected)
    options << %(<option value="#{html_escape(value.to_s)}"#{selected_attribute}><fw:intl>#{html_escape(text.to_s)}</fw:intl></option>)
  end

  options_for_select.join("\n")
end

#intl_select(object, method, choices, options = {}, html_options = {}) ⇒ Object



22
23
24
# File 'lib/config/initializers/intl_select.rb', line 22

def intl_select(object, method, choices, options = {}, html_options = {})
  InstanceTag.new(object, method, self, nil, options.delete(:object)).to_intl_select_tag(choices, options, html_options)
end