function no_autocomplete_form_alter in No Autocomplete 6
Same name and namespace in other branches
- 7 no_autocomplete.module \no_autocomplete_form_alter()
Implements hook_form_alter() to turn off autocomplete on key forms.
_state _id
Parameters
$form:
File
- ./no_autocomplete.module, line 48 
- no_autocomplete.module
Code
function no_autocomplete_form_alter(&$form, $form_state, $form_id) {
  # Add to the user login form.
  # user_login and user_profile_form
  if (substr($form_id, 0, 10) == 'user_login' && variable_get('no_autocomplete_login_form', FALSE)) {
    if (empty($form['pass']['#attributes'])) {
      $form['pass']['#attributes'] = array();
    }
    $form['pass']['#attributes']['autocomplete'] = 'off';
  }
  # Remove autofill from the user edit form
  if ($form_id == 'user_profile_form' && variable_get('no_autocomplete_profile_form', FALSE)) {
    $form['#attributes']['autocomplete'] = 'off';
  }
}