Search code examples
drupal-6password-confirmation

Remove default password value in drupal 6 password_confirm


I have this code for an email settings form that the user will input the email address, password, etc.

$form['mail_settings']['user_pass'] = array(
'#type' => 'password_confirm',
'#description' => t('your password')
);

$form['mail_settings']['user_signature'] = array(
'#type' => 'textfield'
'#description' => t('custm signature')
);

What I wanted to achieve is to have the user be able to change his signature anytime without having to re-enter his password all over again.

What's happening right now is that every time I load this settings page there's a default value for the password and blank for the password confirmation.

So, if the user forgets to input his password again, the form displays an error. Or rather the it will create a validation error.

What should be done here?


Solution

  • Came up with a different solution. It turned out that my browser's password chain (saved passwords) is responsible for adding the default value in the password field.

    The solution was just, if password field is empty: update password using the old one; else if not empty update password with the new one.