You are here

public function ConfigForm::buildForm in Private Message 8

Same name and namespace in other branches
  1. 8.2 src/Form/ConfigForm.php \Drupal\private_message\Form\ConfigForm::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/ConfigForm.php, line 32

Class

ConfigForm
Defines the configuration form for the private message module.

Namespace

Drupal\private_message\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('private_message.settings');
  $form['enable_email_notifications'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable email notifications'),
    '#default_value' => $config
      ->get('enable_email_notifications'),
  ];
  $form['send_by_default'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Default action'),
    '#options' => [
      $this
        ->t('Do not send mails (users can opt-in)'),
      $this
        ->t('Send mails (users can opt-out)'),
    ],
    '#default_value' => (int) $config
      ->get('send_by_default'),
    '#states' => [
      'visible' => [
        ':input[name="enable_email_notifications"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $form['hide_form_filter_tips'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Hide filter tips'),
    '#description' => $this
      ->t('If this box is checked, the text formats description on the private message form will be removed'),
    '#default_value' => (int) $config
      ->get('hide_form_filter_tips'),
  ];
  return parent::buildForm($form, $form_state);
}