I am trying to create a small module to turn off autocomplete for password for user login.
This is for PCI compliance and I think something that more people will look for.
I have never put a module together and have the following code, thanks to emunications.com.
I installed this but got the two errors at the bottom of this post. Can anyone help point me in the right direction?
Many thanks,
// $Id: autocomplete.module, v 1.2 2011/02/07
function autocomplete_form_user_login_alter(&$form, &$form_state, $form_id) {
$form['#attributes'][]['autocomplete'] = 'off';
}
function autocomplete_form_user_login_block_alter(&$form, &$form_state, $form_id) {
$form['#attributes'][]['autocomplete'] = 'off';
}
* warning: Missing argument 3 for autocomplete_form_user_login_block_alter() in /home/coghlanc/public_html/modules/autocomplete/autocomplete.module on line 6.
* warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/coghlanc/public_html/includes/bootstrap.inc on line 857.
Comments
You only need the $form_id
You only need the $form_id argument if you are using basic hook_form_alter(). You are altering a specific form, user_login, so you don't need and won't get the $form_id. So you should have:
Thanks, I have made the
Thanks, I have made the change and now only have a single error, below:
Haven't a clue why this would appear based upon the simple code in this module.
warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/coghlanc/public_html/includes/bootstrap.inc on line 857.
$form['#attributes'][]['autoc
should be
Just posting in case future
Just posting in case future visitors has the same issue.
I re-inserted the [] in the code so what worked finally was this:
$form['attributes'][]['autocomplete'] = 'off';
Thanks for your help
Paul
It seems someone turned this
It seems someone turned this into a module. I found this thread after posting this critique of the technique.
Note that all this module has done is hide the autocomplete. Someone could still use it if they can figure out that it would exist.
I wonder what module was adding this feature - it could have been possible to just disable that.
--
Morris Animal Foundation
I don't believe the OP is
I don't believe the OP is talking about an autocomplete in the Drupal sense, just turning off the browser's tendency to remember your username (which is done with an HTML attribute on the input element)
Ah, I see. Thanks for
Ah, I see. Thanks for explaining! I'll admit I didn't look as closely as I should have.
--
Morris Animal Foundation
There's now a module to
There's now a module to achieve this - http://drupal.org/project/pci_update
--
Morris Animal Foundation
No longer for password managed login screens
It is perhaps useful to know that browser manufacturers have started to disable this functionality for password managed login screens: https://bugzilla.mozilla.org/show_bug.cgi?id=956906
Correct, would be great if we
Correct, would be great if we knew the answer now, as we have a "ID" and "Pin" on our site which looks like a username and password field to the browser and it's trying to put site login details in there...
The answer was given earlier
The answer was given earlier in this thread.
Set autocomplete to off.
I tried that but as said
I tried that but as said earlier in the post, some browsers are disabling this feature on password fields, which our PIN field is, so would be great if anyone know a way to set the password to autocomplete off, because the above code is not working
i got a module for it
I got a module for no auto complete attribute that is here https://www.drupal.org/project/no_autocomplete. This is just work for password field and put attributes autocomplete="off".
Drupal Development Company