Sha256: ee4465ccb45eca8defbcd6595fd51d916a6399c9d00fd5f3f20af94e30bbda97

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

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

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

        @legend             = legend
        @caption            = caption
        @hint_text          = hint_text
        @small              = small
        @classes            = classes
        @form_group_classes = form_group_classes
        @block_content      = capture { block.call }
      end

      def html
        Containers::FormGroup.new(@builder, @object_name, @attribute_name, classes: @form_group_classes).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

4 entries across 4 versions & 1 rubygems

Version Path
govuk_design_system_formbuilder-1.2.9 lib/govuk_design_system_formbuilder/containers/check_boxes_fieldset.rb
govuk_design_system_formbuilder-1.2.7 lib/govuk_design_system_formbuilder/containers/check_boxes_fieldset.rb
govuk_design_system_formbuilder-1.2.6 lib/govuk_design_system_formbuilder/containers/check_boxes_fieldset.rb
govuk_design_system_formbuilder-1.2.5 lib/govuk_design_system_formbuilder/containers/check_boxes_fieldset.rb