I'm trying to turn autocomplete off in one of my rails forms. Here's what I've tried so far:
# add it at the form level = form_tag admin_sessions_path, autocomplete: "off" do
That didn't work.
# add it at the element level .panel = label_tag :email = email_field_tag :email, params[:email], autocomplete: 'off'
Neither did that.
# add it to both = form_tag admin_sessions_path, autocomplete: "off" do # add it at the element level .panel = label_tag :email = email_field_tag :email, params[:email], autocomplete: 'off'
When I visit my form, my email address and saved password are already filled-in. What am I doing wrong here? I love rails, but it really drives me mad sometimes.
This can be done in a <form> for a complete form or for specific <input> elements: Add autocomplete="off" onto the <form> element to disable autocomplete for the entire form.
Click the Display tab. Do one of the following: To enable AutoComplete for the text box, select the Enable AutoComplete check box. To disable AutoComplete for the text box, clear the Enable AutoComplete check box.
As of Rails 4+
Disable autocomplete for an entire form with form_tag
:
= form_tag admin_sessions_path, html: { autocomplete: "off" } do
Disable autocomplete for an entire form with form_for
:
= form_for @user, html: { autocomplete: "off" } do |f|
Disable autocomplete for a single form element:
= f.text_field :foo, autocomplete: 'off'
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With