You are here

function views_ui_standard_submit in Views (for Drupal 7) 7.3

Same name and namespace in other branches
  1. 6.3 includes/admin.inc \views_ui_standard_submit()
  2. 6.2 includes/admin.inc \views_ui_standard_submit()

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.

2 string references to 'views_ui_standard_submit'
views_ui_add_item_form in includes/admin.inc
Form to add_item items in the views UI.
views_ui_standard_form_buttons in includes/admin.inc
Provide a standard set of Apply/Cancel/OK buttons for the forms. Also provide a hidden op operator because the forms plugin doesn't seem to properly provide which button was clicked.

File

includes/admin.inc, line 2682
Provides the Views' administrative interface.

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);
  }
}