7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/stimulus_plumbers/form/fields/password.rb', line 7
def password_field(attribute, options = {})
rails_opts, form_field_opts = (options)
reveal = form_field_opts.delete(:reveal) { false }
field = build_field(attribute, form_field_opts)
input_html = if reveal
input_opts = merge_html_options(
rails_opts,
field_theme(:form_input_reveal),
field.html_opts,
{ "data-input-format-target": "input" }
)
build_input_group(
super(attribute, input_opts),
field,
trailing: reveal_button,
"data-controller": "input-format",
"data-input-format-type-value": "password"
)
else
html_opts = merge_html_options(
rails_opts,
field_theme(:form_input, error: field.error?),
field.html_opts
)
super(attribute, html_opts)
end
render_field(field, input_html)
end
|