Sha256: 7c15f79fa58207c09b6c2cdf1ce4a08d1b1b7ccb0427a91c42939304d686a355

Contents?: true

Size: 824 Bytes

Versions: 57

Compression:

Stored size: 824 Bytes

Contents

# frozen_string_literal: true

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

    def input(wrapper_options = nil)
      label_method, value_method = detect_collection_methods # rubocop:disable Lint/UselessAssignment

      merged_input_options = merge_wrapper_options(input_html_options, wrapper_options) # rubocop:disable Lint/UselessAssignment

      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

57 entries across 57 versions & 1 rubygems

Version Path
ui_bibz-4.0.0.beta14 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-4.0.0.beta13 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-4.0.0.beta10 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-4.0.0.beta9 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-4.0.0.beta8 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-4.0.0.beta7 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-4.0.0.beta6 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-4.0.0.beta4 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-4.0.0.beta3 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.13 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.12 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.11 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.10 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.9 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.8 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.7 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.6 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.5 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.4 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.3 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb