You are here

public function SiteAuditConfigForm::buildForm in Site Audit 8.3

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/SiteAuditConfigForm.php, line 62

Class

SiteAuditConfigForm

Namespace

Drupal\site_audit\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $options = [];
  $saved_options = $this
    ->config('site_audit.settings')
    ->get('reports');
  $reports = $this->report_plugin_manager
    ->getDefinitions();
  foreach ($reports as $report) {
    $options[$report['id']] = $report['name'];
  }
  if (empty($saved_options)) {
    $saved_options = [];
  }
  $form['reports'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Site Reports'),
    '#description' => $this
      ->t('Check the box to run any reports on the audit page. If no reports are selected then all reports will be run.'),
    '#options' => $options,
    '#default_value' => $saved_options,
  ];
  return parent::buildForm($form, $form_state);
}