Class: ActionView::Helpers::InstanceTag

Inherits:
Object
  • Object
show all
Defined in:
lib/plugins/option_tags_with_disable/lib/option_tags_will_disable.rb

Instance Method Summary collapse

Instance Method Details

#to_collection_select_tag(collection, value_method, text_method, options, html_options) ⇒ Object



73
74
75
76
77
78
79
80
81
# File 'lib/plugins/option_tags_with_disable/lib/option_tags_will_disable.rb', line 73

def to_collection_select_tag(collection, value_method, text_method, options, html_options)
  html_options = html_options.stringify_keys
  add_default_name_and_id(html_options)
  value = value(object)
  disabled_value = options.has_key?(:disabled) ? options[:disabled] : nil
  (
    "select", add_options(options_from_collection_for_select(collection, value_method, text_method, value, disabled_value), options, value), html_options
  )
end

#to_select_tag(choices, options, html_options) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/plugins/option_tags_with_disable/lib/option_tags_will_disable.rb', line 64

def to_select_tag(choices, options, html_options)
  html_options = html_options.stringify_keys
  add_default_name_and_id(html_options)
  value = value(object)
  selected_value = options.has_key?(:selected) ? options[:selected] : value
  disabled_value = options.has_key?(:disabled) ? options[:disabled] : nil
  ("select", add_options(options_for_select(choices, selected_value, disabled_value), options, selected_value), html_options)
end