You are here

public function FileDownloadSettingsForm::buildForm in File Download 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

modules/file_download_counter/src/FileDownloadSettingsForm.php, line 64

Class

FileDownloadSettingsForm
Configure statistics settings for this site.

Namespace

Drupal\file_download_counter

Code

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

  // Content counter settings.
  $form['content'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('File download counter settings'),
    '#open' => TRUE,
  ];
  $form['content']['file_download_counter_count_downloads'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Count downloads'),
    '#default_value' => $config
      ->get('count_downloads'),
    '#description' => $this
      ->t('Increment a counter each time content is downloaded.'),
  ];
  return parent::buildForm($form, $form_state);
}