Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Thangobrind on
Hi,
I have a client who wants some changes to the change password form, this includes adding placeholder text to the form fields.
I have added placeholder text using a process handler as outlined in https://www.drupal.org/node/1892214#comment-7211662
However adding this placeholder causes the 'password strength meter' and the 'strong password advice' box to disappear.
Any advice on getting these to work together?
function MYMODULE_form_user_pass_reset_alter(&$form, &$form_state, $form_id) {
$form['account']['pass']['#process'] = array('form_process_password_confirm', '_MYMODULE_process_password_confirm');
}
function _MYMODULE_process_password_confirm($element)
{
$element['pass1']['#attributes']['placeholder'] = t('Enter new password');
$element['pass2']['#attributes']['placeholder'] = t('Confirm new password');
return $element;
}
Thanks
Comments
SOLVED
Ok I was able to fix this by delving into the source code of the user module.
It turns out the process handler I wrote was causing the call to the original process handler to be overwritten.
This original process handler function is what adds the code that deals with password strength meter etc.
In case anyone else gets this problem my solution was to call the original process handler from my new one.
Interestingly the original function 'user_form_process_password_confirm' has a nice little bit of code in it to stop it running more than once, which means i could use and not be too concerned about knock-on effects.