PasswordSettingsForm.php in View Password 8.5
File
src/Form/PasswordSettingsForm.php
View source
<?php
namespace Drupal\view_password\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class PasswordSettingsForm extends ConfigFormBase {
public function getFormId() {
return 'password_settings_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$config = $this
->config('view_password.settings');
$form['form_id_pwd'] = [
'#type' => 'textarea',
'#title' => $this
->t('Enter the form id here.'),
'#description' => $this
->t('Please enter the form id(s) by separating it with a comma. Here the default is user_login_form. You can remove and save the form if you do not want to display the password for this form.'),
'#default_value' => $config
->get('form_ids'),
];
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('view_password.settings')
->set('form_ids', $form_state
->getValue('form_id_pwd'))
->save();
parent::submitForm($form, $form_state);
}
protected function getEditableConfigNames() {
return [
'view_password.settings',
];
}
}