You are here

public function GAPushSettingsForm::buildForm in GA Push 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

src/Form/GAPushSettingsForm.php, line 24

Class

GAPushSettingsForm
GA Push Settings Form.

Namespace

Drupal\ga_push\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('ga_push.settings');
  $elements = ga_push_get_methods_option_list(NULL, FALSE);
  $form['google_analytics_id'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Google Analytics id'),
    'description' => $this
      ->t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, <a href=":analytics">register your site with Google Analytics</a>, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. <a href=":webpropertyid">Find more information in the documentation</a>.', [
      ':analytics' => 'https://marketingplatform.google.com/about/analytics/',
      ':webpropertyid' => Url::fromUri('https://developers.google.com/analytics/resources/concepts/gaConceptsAccounts', [
        'fragment' => 'webProperty',
      ])
        ->toString(),
    ]),
    '#default_value' => $config
      ->get('google_analytics_id'),
  ];
  $form['ga_push_default_method'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Default method'),
    '#options' => $elements,
    '#default_value' => $config
      ->get('default_method'),
  ];
  $form['ga_push_debug'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Debug mode'),
    '#description' => $this
      ->t('Active the debug mode: log GA push requests.'),
    '#default_value' => $config
      ->get('debug'),
  ];
  return parent::buildForm($form, $form_state);
}