You are here

public function SettingsForm::buildForm in Multiple E-mail Addresses 2.x

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 35
Contains \Drupal\multiple_email\Form\SettingsForm.

Class

SettingsForm
Form builder for the admin settings page.

Namespace

Drupal\multiple_email\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $config_settings = $this
    ->config('multiple_email.settings');
  $config_mail = $this
    ->config('multiple_email.mail');
  $form['hide_field'] = array(
    '#type' => 'select',
    '#title' => t('Hide E-mail Field'),
    '#description' => t('Hides the e-mail field when editing a user'),
    '#options' => array(
      'No',
      'Yes',
    ),
    '#default_value' => $config_settings
      ->get('hide_field'),
  );
  $form['edit_emails'] = array(
    '#type' => 'select',
    '#title' => t('Allow editing of emails'),
    '#description' => t('Allows editing of e-mail addresses. It is equivalent to deleting and adding a new e-mail address, as edited emails must be re-confirmed. If enabled, e-mail addresses (excluding primary) may be edited via the multiple e-mail tab.'),
    '#options' => array(
      'No',
      'Yes',
    ),
    '#default_value' => $config_settings
      ->get('edit_emails'),
  );
  $form['confirm_attempts'] = array(
    '#type' => 'textfield',
    '#size' => 4,
    '#title' => t('Confirm Attempts'),
    '#description' => t('How many times a user enters a confirmation code before a new one is generated. If set to 0, no new codes are sent after the first one.'),
    '#default_value' => $config_settings
      ->get('confirm.attempts'),
  );
  $form['confirm_deadline'] = array(
    '#type' => 'textfield',
    '#size' => 4,
    '#title' => t('Confirm Days'),
    '#description' => t('How many days a user has to enter a confirmation code. If 0, emails pending confirmation do not expire.'),
    '#default_value' => $config_settings
      ->get('confirm.deadline'),
  );
  $vars = '!username, !site, !email, !confirm_code, !confirm_url, !confirm_deadline';
  $form['confirmation_subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Confirmation E-mail Subject'),
    '#description' => t('Customize the subject of the message to be sent when a user adds a new e-mail to their account.') . '<br/>' . t('Available variables are:') . $vars,
    '#default_value' => $config_mail
      ->get('confirmation.subject'),
  );
  $form['confirmation_body'] = array(
    '#type' => 'textarea',
    '#title' => t('Confirmation E-mail Body'),
    '#description' => t('Customize the body of the message to be sent when a user adds a new e-mail to their account.') . '<br/>' . t('Available variables are:') . $vars,
    '#default_value' => $config_mail
      ->get('confirmation.body'),
  );
  $form['expiration_subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Expire E-mail Subject'),
    '#description' => t('Customize the subject of the message to be sent when an unconfirmed e-mail address expires.') . '<br/>' . t('Available variables are:') . $vars,
    '#default_value' => $config_mail
      ->get('expiration.subject'),
  );
  $form['expiration_body'] = array(
    '#type' => 'textarea',
    '#title' => t('Expire E-mail Body'),
    '#description' => t('Customize the body of the message to be sent when an unconfirmed e-mail address expires.') . '<br/>' . t('Available variables are:') . $vars,
    '#default_value' => $config_mail
      ->get('expiration.body'),
  );
  return $form;
}