Class: GOVUKDesignSystemFormBuilder::Elements::Date

Inherits:
Base
  • Object
show all
Includes:
Traits::Error, Traits::HTMLClasses, Traits::Hint, Traits::Supplemental
Defined in:
lib/govuk_design_system_formbuilder/elements/date.rb

Constant Summary collapse

SEGMENTS =
{ day: '3i', month: '2i', year: '1i' }.freeze
MULTIPARAMETER_KEY =
{ day: 3, month: 2, year: 1 }.freeze

Instance Method Summary collapse

Methods included from Traits::HTMLClasses

#build_classes

Methods included from Traits::Supplemental

#supplemental_id

Methods included from Traits::Hint

#hint_id

Methods included from Traits::Error

#error_id

Methods inherited from Base

#field_id, #to_s

Constructor Details

#initialize(builder, object_name, attribute_name, legend:, caption:, hint:, omit_day:, maxlength_enabled:, form_group:, wildcards:, date_of_birth: false, **kwargs, &block) ⇒ Date

Returns a new instance of Date.


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/govuk_design_system_formbuilder/elements/date.rb', line 14

def initialize(builder, object_name, attribute_name, legend:, caption:, hint:, omit_day:, maxlength_enabled:, form_group:, wildcards:, date_of_birth: false, **kwargs, &block)
  super(builder, object_name, attribute_name, &block)

  @legend            = legend
  @caption           = caption
  @hint              = hint
  @date_of_birth     = date_of_birth
  @omit_day          = omit_day
  @maxlength_enabled = maxlength_enabled
  @form_group        = form_group
  @wildcards         = wildcards
  @html_attributes   = kwargs
end

Instance Method Details

#htmlObject


28
29
30
31
32
33
34
# File 'lib/govuk_design_system_formbuilder/elements/date.rb', line 28

def html
  Containers::FormGroup.new(*bound, **@form_group, **@html_attributes).html do
    Containers::Fieldset.new(*bound, **fieldset_options).html do
      safe_join([supplemental_content, hint_element, error_element, date])
    end
  end
end