You are here

function rpt_form_user_admin_settings_alter in Registration Password Token 8

Implements hook_form_FORM_ID_alter().

File

./rpt.module, line 14
Registration Password Token module.

Code

function rpt_form_user_admin_settings_alter(&$form, FormStateInterface $form_state) {
  $settings = \Drupal::config('rpt.settings');

  // Add checkbox with setting of password automatic generation.
  $form['registration_cancellation']['rpt_password_generate'] = [
    '#type' => 'checkbox',
    '#title' => t('Generate password automatically'),
    '#description' => t('Hide password fields on user register form.'),
    '#default_value' => $settings
      ->get('password_generate'),
    '#weight' => 0,
  ];
  $form['registration_cancellation']['rpt_password_length'] = [
    '#type' => 'textfield',
    '#title' => t('Password length'),
    '#description' => t('Length for generated password.'),
    '#default_value' => $settings
      ->get('password_length'),
    '#weight' => 1,
  ];

  // Add submit handler to save rpt configuration.
  $form['#submit'][] = 'rpt_user_admin_settings_submit';
}