Sha256: b1c8ff37004752fbe463682f2944215640b1f17b9d7b9a47314b5d88e8f82b5f

Contents?: true

Size: 1.43 KB

Versions: 32

Compression:

Stored size: 1.43 KB

Contents

# = simple_form_for @thing do |f|
#   = f.input :breakfast, :as => :effective_radio_buttons, :collection => ['Eggs', 'Bacon'], images => [asset_path('eggs.png'), asset_path('bacon.png')]

if defined?(SimpleForm)

  class EffectiveRadioButtonsInput < SimpleForm::Inputs::CollectionRadioButtonsInput
    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(' ')

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

  end

end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
effective_form_inputs-1.3.0 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.2.9 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.2.8 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.2.7 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.2.6 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.2.5 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.2.4 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.2.3 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.2.2 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.2.1 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.2.0 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.1.15 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.1.14 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.1.13 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.1.12 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.1.11 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.1.10 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.1.9 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.1.8 app/models/inputs/effective_radio_buttons_input.rb
effective_form_inputs-1.1.7 app/models/inputs/effective_radio_buttons_input.rb