Sha256: fb725903f467263d20793d0cb2d5ffbd332a97644c32339b91d6aaafb280fa84

Contents?: true

Size: 783 Bytes

Versions: 25

Compression:

Stored size: 783 Bytes

Contents

module GOVUKDesignSystemFormBuilder
  module Elements
    module CheckBoxes
      class Label < Base
        using PrefixableArray

        include Traits::Localisation

        def initialize(builder, object_name, attribute_name, checkbox, value:, link_errors: true)
          super(builder, object_name, attribute_name)

          @checkbox    = checkbox
          @value       = value
          @link_errors = link_errors
        end

        def html
          @checkbox.label(for: field_id(link_errors: @link_errors), class: label_classes) do
            [localised_text(:label), @checkbox.text, @value].compact.first
          end
        end

      private

        def label_classes
          %w(label checkboxes__label).prefix(brand)
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
govuk_design_system_formbuilder-2.1.7b1 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.1.6 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.1.5 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.1.4 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.1.3 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.1.2 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.1.1 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.1.0 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.0.0 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.0.0b4 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-1.2.9 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.0.0b3 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.0.0b2 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.0.0b1 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-1.2.7 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-1.2.6 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-1.2.5 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-1.2.4 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-1.2.3 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-1.2.2 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb