Class: GOVUKDesignSystemFormBuilder::Elements::Password

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

Defined Under Namespace

Classes: I18nAttr

Instance Method Summary collapse

Methods included from Traits::HTMLClasses

#build_classes

Methods included from Traits::HTMLAttributes

#attributes

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, label:, caption:, hint:, form_group:, show_password_text:, hide_password_text:, show_password_aria_label_text:, hide_password_aria_label_text:, password_hidden_announcement_text:, password_shown_announcement_text:, **kwargs, &block) ⇒ Password

Returns a new instance of Password.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/govuk_design_system_formbuilder/elements/password.rb', line 14

def initialize(builder, object_name, attribute_name, label:, caption:, hint:, form_group:, show_password_text:, hide_password_text:, show_password_aria_label_text:, hide_password_aria_label_text:, password_hidden_announcement_text:, password_shown_announcement_text:, **kwargs, &block)
  super(builder, object_name, attribute_name, &block)

  @label           = label
  @caption         = caption
  @hint            = hint
  @form_group      = form_group
  @html_attributes = kwargs

  @show_password_text = show_password_text
  @hide_password_text = hide_password_text

  @show_password_aria_label_text = show_password_aria_label_text
  @hide_password_aria_label_text = hide_password_aria_label_text

  @password_shown_announcement_text = password_shown_announcement_text
  @password_hidden_announcement_text = password_hidden_announcement_text
end

Instance Method Details

#htmlObject



33
34
35
36
37
# File 'lib/govuk_design_system_formbuilder/elements/password.rb', line 33

def html
  Containers::FormGroup.new(*bound, **form_group_options).html do
    safe_join([label_element, hint_element, error_element, password_input_and_button])
  end
end