You are here

function google_tag_container_form in GoogleTagManager 7.2

Form constructor for the container form.

See also

google_tag_container_form_validate()

google_tag_container_form_submit()

1 call to google_tag_container_form()
GTMContainerExport::edit_form in plugins/export_ui/container.php
Provide the actual editing form.

File

includes/form/container.inc, line 18
Contains the container form callbacks.

Code

function google_tag_container_form(&$form, &$form_state) {
  module_load_include('inc', 'google_tag', 'includes/variable');

  // Gather data.
  // @todo Set this on validation errors.
  $default_tab = !empty($form_state['default_tab']) ? $form_state['default_tab'] : '';

  // Build form elements.
  $description = t('On this and the following tabs, specify the conditions on which the GTM JavaScript snippet will either be inserted on or omitted from the page response, thereby enabling or disabling tracking and other analytics. All conditions must be satisfied for the snippet to be inserted. The snippet will be omitted if any condition is not met.');
  $text = t('The settings affecting the snippet contents for this container.');
  $suffix = '<div id="edit-default--description" class="description">' . $text . '</div>';
  $groups = array(
    'general' => array(
      'title' => t('General'),
      'collapse' => FALSE,
    ),
    'advanced' => array(
      'title' => t('Advanced'),
    ),
  );
  $form['settings'] = array(
    '#type' => 'vertical_tabs',
    '#default_tab' => $default_tab ? $default_tab : 'edit-general',
    '#attributes' => array(
      'class' => array(
        'google-tag',
      ),
    ),
    '#prefix' => '<strong>' . t('Container settings') . '</strong>',
    '#suffix' => $suffix,
  );
  foreach ($groups as $group => $items) {
    $form['settings'][$group] = google_tag_fieldset($group, $items, $form_state['item']);
  }
  $groups = google_tag_condition_filter();
  $text = t('The snippet insertion conditions for this container.');
  $suffix = '<div id="edit-default--description" class="description">' . $text . '</div>';
  $form['conditions'] = array(
    '#type' => 'vertical_tabs',
    '#default_tab' => $default_tab ? $default_tab : 'edit-path',
    '#attributes' => array(
      'class' => array(
        'google-tag',
      ),
    ),
    '#attached' => array(
      'css' => array(
        drupal_get_path('module', 'google_tag') . '/css/google_tag.admin.css',
      ),
      'js' => array(
        drupal_get_path('module', 'google_tag') . '/js/google_tag.admin.js',
      ),
    ),
    '#prefix' => '<strong>' . t('Insertion conditions') . '</strong>',
    '#suffix' => $suffix,
  );
  foreach ($groups as $group => $items) {
    $form['conditions'][$group] = google_tag_fieldset($group, $items, $form_state['item']);
  }
  $form['#after_build'] = array(
    'google_tag_container_form_after_build',
  );
}