You are here

private function BlockerSettingsForm::eventFormContainer in Cookie Content Blocker 8

Create a container to configure event settings.

Parameters

string $type: The type of the event.

Return value

array The event form container.

1 call to BlockerSettingsForm::eventFormContainer()
BlockerSettingsForm::buildForm in src/Form/BlockerSettingsForm.php
Form constructor.

File

src/Form/BlockerSettingsForm.php, line 214

Class

BlockerSettingsForm
Form builder to manage settings related to the Cookie content blocker.

Namespace

Drupal\cookie_content_blocker\Form

Code

private function eventFormContainer(string $type) : array {
  $defaults = $this
    ->config('cookie_content_blocker.settings')
    ->get('consent_awareness.' . $type . '.event') ?? [];
  $container = [];
  $container['name'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('JavaScript event name'),
    '#description' => $this
      ->t('The event for the element selected below.'),
    '#default_value' => $defaults['name'] ?? '',
    '#element_validate' => [
      [
        $this,
        'stripWhitespaces',
      ],
    ],
  ];
  $container['selector'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('JavaScript event DOM element selector'),
    '#description' => $this
      ->t("The jQuery selector of the DOM element the above event is associated with, omit the jQuery('') or \$('') part. E.g. 'window' or '.some-class > .other-child-class' (without quotes)."),
    '#default_value' => $defaults['selector'] ?? '',
    '#element_validate' => [
      [
        $this,
        'stripWhitespaces',
      ],
    ],
  ];
  return $container;
}