You are here

function password_eye_form_alter in Password Eye 8

Same name and namespace in other branches
  1. 2.0.x password_eye.module \password_eye_form_alter()

Implements hook_form_alter().

File

./password_eye.module, line 30
Contains password_eye.module.

Code

function password_eye_form_alter(&$form, &$form_state, $form_id) {
  $config = \Drupal::service('config.factory')
    ->getEditable('password_eye.settings');
  $password_id[] = $config
    ->get('password_eye.form_id_password');
  $frm_id = explode(',', $password_id[0]);
  foreach ($frm_id as $frmId) {
    if ($form_id == $frmId) {

      // Adding a class else the js is adding to all forms.
      $form['#attributes']['class'][] = 'pwd-see';

      // Adding js to the form that has the id in the config form.
      $form['#attached']['library'][] = 'password_eye/pwd_eye_lib';
    }
  }
}