NoReqNewPassSettingsForm.php in No Request New Password 8
File
src/Form/NoReqNewPassSettingsForm.php
View source
<?php
namespace Drupal\noreqnewpass\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class NoReqNewPassSettingsForm extends ConfigFormBase {
public function getFormId() {
return 'noreqnewpass_admin_settings';
}
protected function getEditableConfigNames() {
return [
'noreqnewpass.settings_form',
];
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('noreqnewpass.settings_form');
$form['noreqnewpass_disable'] = [
'#type' => 'checkbox',
'#title' => 'Disable Request new password link',
'#default_value' => $config
->get('noreqnewpass_disable'),
'#description' => 'If checked, Request new password link will be disabled.',
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('noreqnewpass.settings_form')
->set('noreqnewpass_disable', $form_state
->getValue('noreqnewpass_disable'))
->save();
parent::submitForm($form, $form_state);
}
}