Sha256: 020f4d20bc14f54190ae3702d6a6a93ffc726b64d4bf25efb85d79ce21e72736

Contents?: true

Size: 744 Bytes

Versions: 17

Compression:

Stored size: 744 Bytes

Contents

module GOVUKDesignSystemFormBuilder
  module Containers
    class FormGroup < Base
      def initialize(builder, object_name, attribute_name, classes: nil, **kwargs)
        super(builder, object_name, attribute_name)

        @classes         = classes
        @html_attributes = kwargs
      end

      def html(&block)
        tag.div(class: classes, **@html_attributes, &block)
      end

    private

      def classes
        [form_group_class, error_class, custom_classes].flatten.compact
      end

      def form_group_class
        %(#{brand}-form-group)
      end

      def error_class
        %(#{brand}-form-group--error) if has_errors?
      end

      def custom_classes
        Array.wrap(@classes)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
govuk_design_system_formbuilder-2.7.1 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.7.0 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.6.0 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.6.0b1 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.5.3 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.5.2 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.5.1 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.5.1b1 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.5.0 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.4.0 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.3.0 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.3.0b1 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.2.0 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.1.9 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.1.8 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.1.7 lib/govuk_design_system_formbuilder/containers/form_group.rb
govuk_design_system_formbuilder-2.1.7b2 lib/govuk_design_system_formbuilder/containers/form_group.rb