Sha256: 2f2b0b4664d0c72d0fc6aca17cc8ce231c3fa2da748c72f9b4454df544f7659b

Contents?: true

Size: 930 Bytes

Versions: 22

Compression:

Stored size: 930 Bytes

Contents

# frozen_string_literal: true

module Primer
  module Forms
    module Dsl
      # :nodoc:
      class RadioButtonInput < Input
        attr_reader :name, :value, :label, :nested_form_block, :nested_form_arguments

        def initialize(name:, value:, label:, **system_arguments)
          @name = name
          @value = value
          @label = label

          super(**system_arguments)

          yield(self) if block_given?
        end

        # radio buttons cannot be invalid, as both selected and unselected are valid states
        def valid?
          true
        end

        def to_component
          RadioButton.new(input: self)
        end

        def nested_form(**system_arguments, &block)
          @nested_form_arguments = system_arguments
          @nested_form_block = block
        end

        # :nocov:
        def type
          :radio_button
        end
        # :nocov:
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.20.0 lib/primer/forms/dsl/radio_button_input.rb
primer_view_components-0.16.1 lib/primer/forms/dsl/radio_button_input.rb
primer_view_components-0.16.0 lib/primer/forms/dsl/radio_button_input.rb
openproject-primer_view_components-0.19.0 lib/primer/forms/dsl/radio_button_input.rb
primer_view_components-0.15.1 lib/primer/forms/dsl/radio_button_input.rb
primer_view_components-0.15.0 lib/primer/forms/dsl/radio_button_input.rb
openproject-primer_view_components-0.18.1 lib/primer/forms/dsl/radio_button_input.rb
openproject-primer_view_components-0.17.1 lib/primer/forms/dsl/radio_button_input.rb
openproject-primer_view_components-0.17.0 lib/primer/forms/dsl/radio_button_input.rb
primer_view_components-0.14.0 lib/primer/forms/dsl/radio_button_input.rb
openproject-primer_view_components-0.16.0 lib/primer/forms/dsl/radio_button_input.rb
openproject-primer_view_components-0.15.0 lib/primer/forms/dsl/radio_button_input.rb
openproject-primer_view_components-0.14.0 lib/primer/forms/dsl/radio_button_input.rb
openproject-primer_view_components-0.13.1 lib/primer/forms/dsl/radio_button_input.rb
primer_view_components-0.13.2 lib/primer/forms/dsl/radio_button_input.rb
primer_view_components-0.13.1 lib/primer/forms/dsl/radio_button_input.rb
openproject-primer_view_components-0.13.0 lib/primer/forms/dsl/radio_button_input.rb
primer_view_components-0.13.0 lib/primer/forms/dsl/radio_button_input.rb
primer_view_components-0.12.0 lib/primer/forms/dsl/radio_button_input.rb
primer_view_components-0.11.0 lib/primer/forms/dsl/radio_button_input.rb