Sha256: 3d5d9046375f3f6f9daf54e2d27e5b5e7e2329cc9cbc700570ee8d35d20966c0

Contents?: true

Size: 788 Bytes

Versions: 18

Compression:

Stored size: 788 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.to_s
          end
        end

      private

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
govuk_design_system_formbuilder-2.7.2 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.7.1 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.7.0 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.6.0 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.6.0b1 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.5.3 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.5.2 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.5.1 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.5.1b1 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.5.0 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.4.0 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.3.0 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.3.0b1 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.2.0 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.1.9 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.1.8 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.1.7 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
govuk_design_system_formbuilder-2.1.7b2 lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb