You are here

public function YandexMetricsReportsSettingsForm::buildForm in Yandex.Metrics 8.2

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

yandex_metrics_reports/src/Form/YandexMetricsReportsSettingsForm.php, line 33
Contains \Drupal\yandex_metrics_reports\Form\YandexMetricsReportsSettingsForm.

Class

YandexMetricsReportsSettingsForm
Provides a reports settings form.

Namespace

Drupal\yandex_metrics_reports\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['reports'] = array(
    '#type' => 'fieldset',
    '#title' => t('Reports visibility settings'),
    '#description' => t('Choose reports to display on Yandex.Metrics Summary Report page.'),
  );
  $reports = yandex_metrics_reports_get_list(TRUE);
  foreach ($reports as $report_name => $report_data) {
    $form['reports'][$report_name . '_visible'] = array(
      '#type' => 'checkbox',
      '#title' => $report_data['title'],
      '#default_value' => \Drupal::state()
        ->get('yandex_services_reports_' . $report_name . '_visible') ?: FALSE,
    );
  }
  return parent::buildForm($form, $form_state);
}