You are here

function google_tag_settings_form in GoogleTagManager 7

Same name and namespace in other branches
  1. 7.2 includes/form/settings.inc \google_tag_settings_form()

Form constructor for the module settings form.

See also

google_tag_settings_form_validate()

google_tag_settings_form_submit()

1 string reference to 'google_tag_settings_form'
_google_tag_menu in includes/info.inc
Implements hook_menu().

File

includes/admin.inc, line 18
Contains the administrative page and form callbacks.

Code

function google_tag_settings_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'] : '';
  $description = t('On this and the next two tabs, specify the conditions on which the GTM JavaScript snippet will either be included in or excluded from the page response, thereby enabling or disabling tracking and other analytics. All conditions must be satisfied for the snippet to be included. The snippet will be excluded if any condition is not met.<br /><br />On this tab, specify the path condition.');
  $groups = array(
    'general' => array(
      'title' => t('General'),
      'collapse' => FALSE,
    ),
    'path' => array(
      'title' => t('Page paths'),
      'description' => $description,
    ),
    'role' => array(
      'title' => t('User roles'),
      'description' => t('On this tab, specify the user role condition.'),
    ),
    'status' => array(
      'title' => t('Response statuses'),
      'description' => t('On this tab, specify the page response status condition.'),
    ),
    'advanced' => array(
      'title' => t('Advanced'),
    ),
  );

  // Build form elements.
  $form['tabs'] = array(
    '#type' => 'vertical_tabs',
    '#default_tab' => $default_tab ? $default_tab : 'edit-general',
    '#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',
      ),
    ),
  );
  foreach ($groups as $group => $items) {
    $form['tabs'][$group] = google_tag_fieldset($group, $items);
  }
  $form['#after_build'] = array(
    'google_tag_settings_form_after_build',
  );
  return system_settings_form($form);
}