Sha256: fc6ab62767094e52a79e48729b3d8a757345d2dc415761b79625547330d72dbb

Contents?: true

Size: 1.39 KB

Versions: 10

Compression:

Stored size: 1.39 KB

Contents

require_relative '../radio'

module CCS
  module Components
    module GovUK
      class Field < Base
        class Inputs < Field
          class Item < Base
            class Radio < Item
              # = GOV.UK Field Inputs Radio form tag
              #
              # This is used to generate an individual radio item using +form.check_box+

              class Form < Radio
                # @param (see CCS::Components::GovUK::Field::Items::Item::Radio#initialize)
                #
                # @option (see CCS::Components::GovUK::Field::Items::Item::Radio#initialize)

                def initialize(attribute:, label:, **options)
                  super(attribute: attribute, label: label, **options)

                  (label[:attributes] ||= {})[:value] = @value
                  label[:attributes][:for] = @options[:attributes][:id] if @options[:attributes][:id]

                  @label = Label.new(attribute: attribute, form: @options[:form], context: @context, **label)
                end

                # Generates the HTML for the radio input
                #
                # @return [ActiveSupport::SafeBuffer]

                def render
                  super() do
                    @options[:form].radio_button(@attribute, @value, **@options[:attributes])
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ccs-frontend_helpers-0.3.0 lib/ccs/components/govuk/field/inputs/item/radio/form.rb
ccs-frontend_helpers-0.2.0 lib/ccs/components/govuk/field/inputs/item/radio/form.rb
ccs-frontend_helpers-0.1.2 lib/ccs/components/govuk/field/inputs/item/radio/form.rb
ccs-frontend_helpers-0.1.1 lib/ccs/components/govuk/field/inputs/item/radio/form.rb
ccs-frontend_helpers-0.1.1.rc.1 lib/ccs/components/govuk/field/inputs/item/radio/form.rb
ccs-frontend_helpers-0.1.0.rc.7 lib/ccs/components/govuk/field/inputs/item/radio/form.rb
ccs-frontend_helpers-0.1.0.rc.6 lib/ccs/components/govuk/field/inputs/item/radio/form.rb
ccs-frontend_helpers-0.1.0.rc.5 lib/ccs/components/govuk/field/inputs/item/radio/form.rb
ccs-frontend_helpers-0.1.0.rc.4 lib/ccs/components/govuk/field/inputs/item/radio/form.rb
ccs-frontend_helpers-0.1.0.rc.3 lib/ccs/components/govuk/field/inputs/item/radio/form.rb