Sha256: dcee32cf548b8d07f3954e1dd030bce1e5fdfa4c0603548fea74c0aa9b3a1bf1

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

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

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

        @inline             = inline
        @small              = small
        @legend             = legend
        @caption            = caption
        @hint_text          = hint_text
        @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, radios])
          end
        end
      end

    private

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

      def radios
        Containers::Radios.new(@builder, inline: @inline, 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/radio_buttons_fieldset.rb
govuk_design_system_formbuilder-1.2.7 lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb
govuk_design_system_formbuilder-1.2.6 lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb
govuk_design_system_formbuilder-1.2.5 lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb