no_autocomplete.module in No Autocomplete 6
File
no_autocomplete.module
View source
<?php
function no_autocomplete_menu() {
$items['admin/settings/no_autocomplete'] = array(
'title' => 'No Autocomplete',
'description' => 'Turn on autocomplete=off for key user forms',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'no_autocomplete_admin_settings_form',
),
'access arguments' => array(
'administer site configuration',
),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function no_autocomplete_form_alter(&$form, $form_state, $form_id) {
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';
}
if ($form_id == 'user_profile_form' && variable_get('no_autocomplete_profile_form', FALSE)) {
$form['#attributes']['autocomplete'] = 'off';
}
}
function no_autocomplete_admin_settings_form() {
$form['no_autocomplete_login_form'] = array(
'#type' => 'checkbox',
'#title' => t('Use "autocomplete=off" on user login form'),
'#default_value' => variable_get('no_autocomplete_login_form', FALSE),
);
$form['no_autocomplete_profile_form'] = array(
'#type' => 'checkbox',
'#title' => t('Use "autocomplete=off" on user profile edit form'),
'#default_value' => variable_get('no_autocomplete_profile_form', FALSE),
);
$form = system_settings_form($form);
return $form;
}