You are here

public function ErrorlogConfigForm::buildForm in Logging and alerts 8

Same name and namespace in other branches
  1. 2.0.x errorlog/src/Form/ErrorlogConfigForm.php \Drupal\errorlog\Form\ErrorlogConfigForm::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

errorlog/src/Form/ErrorlogConfigForm.php, line 36

Class

ErrorlogConfigForm
Provides a setting UI for errorlog.

Namespace

Drupal\errorlog\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('errorlog.settings');
  $form['errorlog'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Error logging for each severity level.'),
    '#description' => $this
      ->t('Check each severity level you want to get logged to the error log.'),
  ];
  foreach (RfcLogLevel::getLevels() as $severity => $description) {
    $key = 'errorlog_' . $severity;
    $form['errorlog'][$key] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Severity: @description', [
        '@description' => Unicode::ucfirst($description
          ->render()),
      ]),
      '#default_value' => $config
        ->get($key) ?: FALSE,
    ];
  }
  return parent::buildForm($form, $form_state);
}