public function MailLoginAdminSettingsForm::buildForm in Mail Login 8
Same name and namespace in other branches
- 8.2 src/Form/MailLoginAdminSettingsForm.php \Drupal\mail_login\Form\MailLoginAdminSettingsForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ MailLoginAdminSettingsForm.php, line 30
Class
- MailLoginAdminSettingsForm
- Configure Mail Login settings.
Namespace
Drupal\mail_login\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = \Drupal::service('config.factory')
->getEditable('mail_login.settings');
$form['general'] = [
'#type' => 'fieldset',
'#title' => $this
->t('General Configurations'),
'#open' => TRUE,
];
$form['general']['mail_login_enabled'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enable login by email address'),
'#default_value' => $config
->get('mail_login_enabled'),
'#description' => $this
->t('This option enables login by email address.'),
];
$form['general']['mail_login_override_login_labels'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Override login form'),
'#default_value' => $config
->get('mail_login_override_login_labels'),
'#description' => $this
->t('This option allows you to override the login form username title/description.'),
];
$form['general']['mail_login_username_title'] = [
'#type' => 'textfield',
'#title' => $this
->t('Login form username title'),
'#default_value' => $config
->get('mail_login_username_title'),
'#states' => [
'required' => [
':input[name="mail_login_override_login_labels"]' => [
'checked' => TRUE,
],
],
'visible' => [
':input[name="mail_login_override_login_labels"]' => [
'checked' => TRUE,
],
],
],
'#description' => $this
->t('Override the username field title.'),
];
$form['general']['mail_login_username_description'] = [
'#type' => 'textfield',
'#title' => $this
->t('Login form username description'),
'#default_value' => $config
->get('mail_login_username_description'),
'#states' => [
'required' => [
':input[name="mail_login_override_login_labels"]' => [
'checked' => TRUE,
],
],
'visible' => [
':input[name="mail_login_override_login_labels"]' => [
'checked' => TRUE,
],
],
],
'#description' => $this
->t('Override the username field description.'),
];
return parent::buildForm($form, $form_state);
}