1 views_ui.admin.inc views_ui_standard_submit($form, &$form_state)

Basic submit handler applicable to all 'standard' forms.

This submit handler determines whether the user wants the submitted changes to apply to the default display or to the current display, and dispatches control appropriately.

File

core/modules/views_ui/views_ui.admin.inc, line 2519
Admin page callbacks for the Views UI module.

Code

function views_ui_standard_submit($form, &$form_state) {
  // Determine whether the values the user entered are intended to apply to
  // the current display or the default display.

  list($was_defaulted, $is_defaulted, $revert) = views_ui_standard_override_values($form, $form_state);

  // Mark the changed section of the view as changed.
  // TODO: Document why we are doing this, and see if we still need it.
  if (!empty($form['#section'])) {
    $form_state['view']->changed_sections[$form['#section']] = TRUE;
  }

  // Based on the user's choice in the display dropdown, determine which display
  // these changes apply to.
  if ($revert) {
    // If it's revert just change the override and return.
    $display = &$form_state['view']->display[$form_state['display_id']];
    $display->handler->options_override($form, $form_state);

    // Don't execute the normal submit handling but still store the changed view into cache.
    views_ui_cache_set($form_state['view']);
    return;
  }
  elseif ($was_defaulted === $is_defaulted) {
    // We're not changing which display these form values apply to.
    // Run the regular submit handler for this form.
  }
  elseif ($was_defaulted && !$is_defaulted) {
    // We were using the default display's values, but we're now overriding
    // the default display and saving values specific to this display.
    $display = &$form_state['view']->display[$form_state['display_id']];
    // options_override toggles the override of this section.
    $display->handler->options_override($form, $form_state);
    $display->handler->options_submit($form, $form_state);
  }
  elseif (!$was_defaulted && $is_defaulted) {
    // We used to have an override for this display, but the user now wants
    // to go back to the default display.
    // Overwrite the default display with the current form values, and make
    // the current display use the new default values.
    $display = &$form_state['view']->display[$form_state['display_id']];
    // options_override toggles the override of this section.
    $display->handler->options_override($form, $form_state);
    $display->handler->options_submit($form, $form_state);
  }

  $submit_handler = $form['#form_id'] . '_submit';
  if (function_exists($submit_handler)) {
    $submit_handler($form, $form_state);
  }
}