n Drupal 8 Add placeholders to "password_confirm" element | CodimTh

Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh


how to add placeholders to password_confirm element?


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;
password placeholder


Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts


Page Facebook