Files

Class/Module Index [+]

Quicksearch

SimpleForm::Inputs::CollectionRadioButtonsInput

Public Instance Methods

input() click to toggle source
# File lib/simple_form/inputs/collection_radio_buttons_input.rb, line 4
def input
  label_method, value_method = detect_collection_methods

  @builder.send("collection_#{input_type}",
    attribute_name, collection, value_method, label_method,
    input_options, input_html_options, &collection_block_for_nested_boolean_style
  )
end
input_options() click to toggle source
# File lib/simple_form/inputs/collection_radio_buttons_input.rb, line 13
def input_options
  options = super
  apply_default_collection_options!(options)
  apply_nested_boolean_collection_options!(options) if nested_boolean_style?
  options
end

Protected Instance Methods

apply_default_collection_options!(options) click to toggle source
# File lib/simple_form/inputs/collection_radio_buttons_input.rb, line 22
def apply_default_collection_options!(options)
  options[:item_wrapper_tag] ||= options.fetch(:item_wrapper_tag, SimpleForm.item_wrapper_tag)
  options[:item_wrapper_class] = [
    item_wrapper_class, options[:item_wrapper_class], SimpleForm.item_wrapper_class
  ].compact.presence

  options[:collection_wrapper_tag] ||= options.fetch(:collection_wrapper_tag, SimpleForm.collection_wrapper_tag)
  options[:collection_wrapper_class] = [
    options[:collection_wrapper_class], SimpleForm.collection_wrapper_class
  ].compact.presence
end
apply_nested_boolean_collection_options!(options) click to toggle source

Force item wrapper to be a label when using nested boolean, to support configuring classes through :item_wrapper_class, and to maintain compatibility with :inline style and default :item_wrapper_tag.

# File lib/simple_form/inputs/collection_radio_buttons_input.rb, line 37
def apply_nested_boolean_collection_options!(options)
  options[:item_wrapper_tag] = :label
end
build_nested_boolean_style_item_tag(collection_builder) click to toggle source
# File lib/simple_form/inputs/collection_radio_buttons_input.rb, line 47
def build_nested_boolean_style_item_tag(collection_builder)
  collection_builder.radio_button + collection_builder.text
end
collection_block_for_nested_boolean_style() click to toggle source
# File lib/simple_form/inputs/collection_radio_buttons_input.rb, line 41
def collection_block_for_nested_boolean_style
  return unless nested_boolean_style?

  proc { |builder| build_nested_boolean_style_item_tag(builder) }
end
generate_label_for_attribute?() click to toggle source

Do not attempt to generate label attributes by default, unless an explicit html option is given. This avoids generating labels pointing to non existent fields.

# File lib/simple_form/inputs/collection_radio_buttons_input.rb, line 58
def generate_label_for_attribute?
  false
end
item_wrapper_class() click to toggle source
# File lib/simple_form/inputs/collection_radio_buttons_input.rb, line 51
def item_wrapper_class
  "radio"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.