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-3.0.0.beta2 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.0.beta1 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.0.alpha12 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.0.alpha11 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.0.alpha10 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.0.alpha9 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.0.alpha8 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.0.alpha6 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.0.alpha5 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.0.alpha3 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-3.0.0.alpha2 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.5.6 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.5.5 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.5.3 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.5.2 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.5.1 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
ui_bibz-2.5.0 lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb