Sha256: 648e44a3b47332f61e1e0f6c64358fd6e99749b2d7b93838c6c342ffb902f1d2

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

module GOVUKDesignSystemFormBuilder
  module Containers
    class CheckBoxesFieldset < Base
      include Traits::Error
      include Traits::Hint

      def initialize(builder, object_name, attribute_name, hint:, legend:, caption:, small:, classes:, form_group:, &block)
        super(builder, object_name, attribute_name, &block)

        @legend        = legend
        @caption       = caption
        @hint          = hint
        @small         = small
        @classes       = classes
        @form_group    = form_group
        @block_content = capture { block.call }
      end

      def html
        Containers::FormGroup.new(@builder, @object_name, @attribute_name, **@form_group).html do
          Containers::Fieldset.new(@builder, @object_name, @attribute_name, **fieldset_options).html do
            safe_join([hint_element, error_element, checkboxes])
          end
        end
      end

    private

      def fieldset_options
        {
          legend: @legend,
          caption: @caption,
          described_by: [error_element.error_id, hint_element.hint_id]
        }
      end

      def checkboxes
        Containers::CheckBoxes.new(@builder, small: @small, classes: @classes).html do
          @block_content
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
govuk_design_system_formbuilder-2.0.0b3 lib/govuk_design_system_formbuilder/containers/check_boxes_fieldset.rb
govuk_design_system_formbuilder-2.0.0b2 lib/govuk_design_system_formbuilder/containers/check_boxes_fieldset.rb
govuk_design_system_formbuilder-2.0.0b1 lib/govuk_design_system_formbuilder/containers/check_boxes_fieldset.rb