Question
how to add placeholders to password_confirm element?
Solution
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_element_info_alter().
*/
function mymodule_element_info_alter(array &$types) {
$types['password_confirm']['#process'][] = "_add_pass_confirm_placeholders";
}
function _add_pass_confirm_placeholders(&$element, FormStateInterface $form_state, &$complete_form) {
$element['pass1']['#placeholder'] = t('Password');
$element['pass2']['#placeholder'] = t('Confirm password');
return $element;
}