You are here

public function StatisticsSettingsForm::buildForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/statistics/src/StatisticsSettingsForm.php \Drupal\statistics\StatisticsSettingsForm::buildForm()
  2. 10 core/modules/statistics/src/StatisticsSettingsForm.php \Drupal\statistics\StatisticsSettingsForm::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

core/modules/statistics/src/StatisticsSettingsForm.php, line 66

Class

StatisticsSettingsForm
Configure statistics settings for this site.

Namespace

Drupal\statistics

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('statistics.settings');

  // Content counter settings.
  $form['content'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Content viewing counter settings'),
    '#open' => TRUE,
  ];
  $form['content']['statistics_count_content_views'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Count content views'),
    '#default_value' => $config
      ->get('count_content_views'),
    '#description' => $this
      ->t('Increment a counter each time content is viewed.'),
  ];
  return parent::buildForm($form, $form_state);
}