You are here

public function SettingsForm::buildForm in Mail Safety 8

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/SettingsForm.php, line 30

Class

SettingsForm
Defines a form for the mail safety settings.

Namespace

Drupal\mail_safety\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('mail_safety.settings');
  $form['enabled'] = [
    '#title' => t('Stop outgoing mails'),
    '#type' => 'checkbox',
    '#description' => t('When Mail Safety is enabled it will stop all outgoing emails from being sent and will send them to either the dashboard and/or the defaut mail address instead.'),
    '#default_value' => $config
      ->get('enabled'),
  ];
  $form['send_mail_to_dashboard'] = [
    '#title' => t('Send mail to dashboard'),
    '#type' => 'checkbox',
    '#description' => t('If enabled, all mails will be sent to the dashboard'),
    '#default_value' => $config
      ->get('send_mail_to_dashboard'),
  ];
  $form['send_mail_to_default_mail'] = [
    '#title' => t('Send mail to default mail'),
    '#type' => 'checkbox',
    '#description' => t('If enabled, all mails will be sent to the the default mail address'),
    '#default_value' => $config
      ->get('send_mail_to_default_mail'),
  ];
  $form['default_mail_address'] = [
    '#title' => t('Default mail address'),
    '#type' => 'textfield',
    '#description' => t('The default email address that outgoing e-mails will be rerouted to if enabled.'),
    '#default_value' => $config
      ->get('default_mail_address'),
  ];
  return parent::buildForm($form, $form_state);
}