Sha256: 881aad966a223cbc97d07808a7c1373cef7bc56b114699800062d130f332f4a2

Contents?: true

Size: 1.22 KB

Versions: 11

Compression:

Stored size: 1.22 KB

Contents

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

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

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

      def html
        Containers::FormGroup.new(*bound, **@form_group).html do
          Containers::Fieldset.new(*bound, **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

11 entries across 11 versions & 1 rubygems

Version Path
govuk_design_system_formbuilder-2.7.1 lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb
govuk_design_system_formbuilder-2.7.0 lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb
govuk_design_system_formbuilder-2.6.0 lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb
govuk_design_system_formbuilder-2.6.0b1 lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb
govuk_design_system_formbuilder-2.5.3 lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb
govuk_design_system_formbuilder-2.5.2 lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb
govuk_design_system_formbuilder-2.5.1 lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb
govuk_design_system_formbuilder-2.5.1b1 lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb
govuk_design_system_formbuilder-2.5.0 lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb
govuk_design_system_formbuilder-2.4.0 lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb
govuk_design_system_formbuilder-2.3.0 lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb