Class: EffectiveRadioButtonsInput

Inherits:
SimpleForm::Inputs::CollectionRadioButtonsInput
  • Object
show all
Defined in:
lib/effective_form_inputs/inputs/effective_radio_buttons_input.rb

Instance Method Summary collapse

Instance Method Details

#input(wrapper_options = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/effective_form_inputs/inputs/effective_radio_buttons_input.rb', line 7

def input(wrapper_options = nil)
  label_method, value_method = (detect_collection_methods rescue [:first, :last])

  options[:collection] = collection
  options[:label_method] = label_method
  options[:value_method] = value_method
  options[:nested_boolean_style] = :nested if nested_boolean_style?

  # Wrapper
  options[:wrapper_html] ||= {}
  options[:wrapper_html][:class] = Array(options[:wrapper_html][:class])

  if options[:images]
    options[:wrapper_html][:class] << 'image_radio_buttons'
  end

  if options[:buttons]
    options[:wrapper_html][:class] << 'button_radio_buttons btn-group inline_radio_buttons'
    options[:wrapper_html][:data] = { toggle: 'buttons' }
  end

  if options[:inline] && !options[:buttons]
    options[:wrapper_html][:class] << 'inline_radio_buttons'
  end

  options[:wrapper_html][:class] = options[:wrapper_html][:class].join(' ')

  Effective::FormBuilderInputs::EffectiveRadioButtons.new(object, object_name, template, attribute_name, input_options, (merge_wrapper_options(input_html_options, wrapper_options) || {})).to_html
end