Drupal - Adding title attribute to #type password_confirm
The password confirm element is converted to two fields in a process function (form_process_password_confirm()
), so adding your own process function to the password element would do the trick.
Per this issue it seems you actually need to overwrite the existing #process array instead of just appending to it, e.g for the user register form password element:
function MYMODULE_form_user_register_form_alter(&$form, &$form_state, $form_id) {
$form['account']['pass']['#process'] = array(
'form_process_password_confirm',
'MYMODULE_password_confirm_process',
'user_form_process_password_confirm'
);
}
function MYMODULE_password_confirm_process($element) {
$element['pass1']['#attributes']['title'] = 'Title';
$element['pass2']['#attributes']['title'] = 'Title2';
return $element;
}