Module: ActionView::Helpers::FormOptionsHelper
- Defined in:
- lib/list_select.rb,
lib/list_select.rb
Instance Method Summary collapse
- #country_select(object, method, priority_countries = nil, options = {}, html_options = {}) ⇒ Object
- #list_options_for_select(list, selected = nil, priority_items = nil) ⇒ Object
- #list_select(object, method, list, options = {}, html_options = {}) ⇒ Object
- #list_select_tag(name, list, options = {}, html_options = {}) ⇒ Object
Instance Method Details
#country_select(object, method, priority_countries = nil, options = {}, html_options = {}) ⇒ Object
53 54 55 56 57 |
# File 'lib/list_select.rb', line 53 def country_select(object, method, priority_countries = nil, = {}, = {}) = .merge(:priority_items => priority_countries) if priority_countries list = .delete(:list) || :countries_cldr list_select(object, method, list, , ) end |
#list_options_for_select(list, selected = nil, priority_items = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/list_select.rb', line 15 def (list, selected = nil, priority_items = nil) = "" items = I18n.translate(list) unless priority_items.blank? += (priority_items.map{|key| [items[key], key.to_s]}, selected) += "<option value=\"\" disabled=\"disabled\">-------------</option>\n" end return + (items.map{|k, v| [v, k.to_s]}.sort, selected) end |
#list_select(object, method, list, options = {}, html_options = {}) ⇒ Object
5 6 7 |
# File 'lib/list_select.rb', line 5 def list_select(object, method, list, = {}, = {}) InstanceTag.new(object, method, self, .delete(:object)).to_list_select_tag(list, , ) end |
#list_select_tag(name, list, options = {}, html_options = {}) ⇒ Object
9 10 11 12 13 |
# File 'lib/list_select.rb', line 9 def list_select_tag(name, list, ={}, = {}) content_tag :select, (list, [:default], [:priority_items]), { "name" => name, "id" => name }.update(.stringify_keys) end |