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

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:, date_of_birth: false, **kwargs, &block) ⇒ Date

Returns a new instance of Date.



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

def initialize(builder, object_name, attribute_name, legend:, caption:, hint:, omit_day:, maxlength_enabled:, form_group:, 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
  @html_attributes   = kwargs
end

Instance Method Details

#htmlObject



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

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