password_eye.module in Password Eye 2.0.x
Same filename and directory in other branches
Contains password_eye.module.
File
password_eye.moduleView source
<?php
/**
* @file
* Contains password_eye.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function password_eye_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the password_eye module.
case 'help.page.password_eye':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('A Utility Module to view password on password fields') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_form_alter().
*/
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';
}
}
}
Functions
Name | Description |
---|---|
password_eye_form_alter | Implements hook_form_alter(). |
password_eye_help | Implements hook_help(). |