Sha256: ccefb60174949acc32faebfa4f338067132055d7abdd79163ee75655d5603c2f

Contents?: true

Size: 754 Bytes

Versions: 38

Compression:

Stored size: 754 Bytes

Contents

module UiBibzInputs
  class UiChoiceGroupInput < CollectionInput#::Inputs::CollectionRadioButtonsInput
    include UiBibz::Ui::Core::Forms::Choices

    def input(wrapper_options = nil)
      label_method, value_method = detect_collection_methods

      merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)

      UiBibz::Ui::Core::Forms::Choices::ChoiceGroup.new(input_options).tap do |bc|
        collection.each do |item|
          opts = { name: "#{ @builder.object.class.name.underscore }[#{ attribute_name }]", value: item[1] }
          opts = opts.merge({ state: :active }) if @builder.object.send(attribute_name).to_s == item[1].to_s
          bc.button item[0], opts
        end
      end.render
    end

  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
ui_bibz-2.4.0 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.15 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.14 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.13 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.12 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.11 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.10 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.9 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.8 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.7 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.6 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.5 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.4 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.3 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.2 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.1 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.3.0 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.2.2 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.2.1 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.2.0 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb