Sha256: b3ae29ea5cf9c736662fcf60128bc4d9909e766f30b9a758525f8d4f781f5843

Contents?: true

Size: 1.49 KB

Versions: 10

Compression:

Stored size: 1.49 KB

Contents

require_relative '../checkbox'

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

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

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

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

                  @options[:attributes][:multiple] = true
                  @options[:attributes][:include_hidden] = false

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

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

                def render
                  super do
                    @options[:form].check_box(@attribute, @options[:attributes], @value)
                  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/checkbox/form.rb
ccs-frontend_helpers-2.0.0 lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb
ccs-frontend_helpers-1.2.0 lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb
ccs-frontend_helpers-1.1.2 lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb
ccs-frontend_helpers-1.1.1 lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb
ccs-frontend_helpers-1.1.0 lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb
ccs-frontend_helpers-1.1.0.beta0 lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb
ccs-frontend_helpers-1.0.0 lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb
ccs-frontend_helpers-0.5.0.beta1 lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb
ccs-frontend_helpers-0.5.0.beta0 lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb