You are here

public function ContainerForm::generalFieldset in GoogleTagManager 8

Fieldset builder for the container settings form.

1 call to ContainerForm::generalFieldset()
ContainerForm::form in src/Form/ContainerForm.php
Gets the actual form array to be built.

File

src/Form/ContainerForm.php, line 140

Class

ContainerForm
Defines the Google tag manager container settings form.

Namespace

Drupal\google_tag\Form

Code

public function generalFieldset(FormStateInterface &$form_state) {
  $container = $this->entity;

  // Build form elements.
  $fieldset = [
    '#type' => 'details',
    '#title' => $this
      ->t('General'),
    '#group' => 'settings',
  ];
  $fieldset['container_id'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Container ID'),
    '#description' => $this
      ->t('The ID assigned by Google Tag Manager (GTM) for this website container. To get a container ID, <a href="https://tagmanager.google.com/">sign up for GTM</a> and create a container for your website.'),
    '#default_value' => $container
      ->get('container_id'),
    '#attributes' => [
      'placeholder' => [
        'GTM-xxxxxx',
      ],
    ],
    '#size' => 12,
    '#maxlength' => 15,
    '#required' => TRUE,
  ];
  $fieldset['weight'] = [
    '#type' => 'weight',
    '#title' => 'Weight',
    '#default_value' => $container
      ->get('weight'),
  ];
  return $fieldset;
}