Module: StimulusPlumbers::Form::Fields::Inputs::Password

Included in:
Builder
Defined in:
lib/stimulus_plumbers/form/fields/inputs/password.rb

Instance Method Summary collapse

Instance Method Details

#password_field(attribute, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/stimulus_plumbers/form/fields/inputs/password.rb', line 8

def password_field(attribute, options = {})
  reveal = options.delete(:reveal) { false }
  Field.new(@template, **options).render(
    object,
    attribute,
    input_id: field_id(attribute)
  ) do |html_opts, opts, error|
    if reveal
      render_reveal_password(merge_html_options(opts, html_opts), error) do |html_options|
        super(attribute, html_options)
      end
    else
      html_options = merge_html_options(opts, html_opts, field_theme(:form_input, error: error))
      super(attribute, html_options)
    end
  end
end