You are here

function google_tag_settings_form_submit in GoogleTagManager 7.2

Same name and namespace in other branches
  1. 7 includes/admin.inc \google_tag_settings_form_submit()

Form submission handler for google_tag_settings_form().

File

includes/form/settings.inc, line 260
Contains the settings form callbacks.

Code

function google_tag_settings_form_submit($form, &$form_state) {
  module_load_include('inc', 'ctools', 'includes/export');

  // @todo Just like fields that change the 'value' during load-save,
  // backup the current form_state 'item' and restore it after save.
  // @todo Add the status property to data.
  $variables = GTMContainerExport::variables_get(TRUE);

  // Set name and label so we can load all rows in config table and then remove
  // the settings item before building the container list page.
  // See google_tag_export_load().
  $values =& $form_state['values'];
  $data['name'] = 'settings';
  $data['label'] = 'Module settings';

  // @todo ctools seems to store this in the variable table for all objects???
  // It relies on config.export.status key
  $data['status'] = TRUE;
  $data += array_intersect_key($form_state['values'], $variables);
  $clone['name'] = 'google_tag.settings';
  $clone['data'] = $data;
  $clone['export_type'] = isset($values['export_type']) ? $values['export_type'] : NULL;
  $clone = (object) $clone;
  $result = ctools_export_crud_save('gtag_config', $clone);

  // @todo If the uri changes, then could rebuild snippets. But let user invoke.
}