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

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

Constant Summary collapse

STIMULUS_CONTROLLER =
"input-revealable"
STIMULUS_ACTION =
"click->#{STIMULUS_CONTROLLER}#toggle".freeze
DEFAULT_AUTOCOMPLETE =
"current-password"

Instance Method Summary collapse

Instance Method Details

#password_field(attribute, floating: nil, revealable: false, **options) ⇒ Object



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

def password_field(attribute, floating: nil, revealable: false, **options)
  html_options = merge_html_options(
    theme.resolve(:form_field_input, floating: floating),
    options,
    { autocomplete: options.delete(:autocomplete) || DEFAULT_AUTOCOMPLETE }
  )
  if revealable
    render_revealable_password(false) do
      super(attribute, merge_html_options(html_options, { data: { input_revealable_target: "input" } }))
    end
  else
    super(attribute, html_options)
  end
end