Skip to main content
Category:

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;
}
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

Search

Page Facebook