Sha256: 99204b175fd311785ff7c2bc897220b46ee27cf8212a2a2ee822c734856686c3

Contents?: true

Size: 1.29 KB

Versions: 10

Compression:

Stored size: 1.29 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 tag
              #
              # This is used to generate an individual radio item using +radio_button_tag+

              class Tag < 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

                  @options[:attributes][:id] ||= "#{sanitize_to_id(@attribute)}_#{sanitize_to_id(@value)}"

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

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

                def render
                  super do
                    context.radio_button_tag(@attribute, @value, @options[:checked], **@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-2.1.0 lib/ccs/components/govuk/field/inputs/item/radio/tag.rb
ccs-frontend_helpers-2.0.0 lib/ccs/components/govuk/field/inputs/item/radio/tag.rb
ccs-frontend_helpers-1.2.0 lib/ccs/components/govuk/field/inputs/item/radio/tag.rb
ccs-frontend_helpers-1.1.2 lib/ccs/components/govuk/field/inputs/item/radio/tag.rb
ccs-frontend_helpers-1.1.1 lib/ccs/components/govuk/field/inputs/item/radio/tag.rb
ccs-frontend_helpers-1.1.0 lib/ccs/components/govuk/field/inputs/item/radio/tag.rb
ccs-frontend_helpers-1.1.0.beta0 lib/ccs/components/govuk/field/inputs/item/radio/tag.rb
ccs-frontend_helpers-1.0.0 lib/ccs/components/govuk/field/inputs/item/radio/tag.rb
ccs-frontend_helpers-0.5.0.beta1 lib/ccs/components/govuk/field/inputs/item/radio/tag.rb
ccs-frontend_helpers-0.5.0.beta0 lib/ccs/components/govuk/field/inputs/item/radio/tag.rb