You are here

public function ViewUI::standardSubmit in Views (for Drupal 7) 8.3

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

views_ui/lib/Drupal/views_ui/ViewUI.php, line 565
Definition of Drupal\views_ui\ViewUI.

Class

ViewUI
Stores UI related temporary settings.

Namespace

Drupal\views_ui

Code

public function standardSubmit($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) = $this
    ->getOverrideValues($form, $form_state);

  // 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 =& $this->displayHandlers[$form_state['display_id']];
    $display
      ->optionsOverride($form, $form_state);

    // Don't execute the normal submit handling but still store the changed view into cache.
    views_ui_cache_set($this);
    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 =& $this->displayHandlers[$form_state['display_id']];

    // optionsOverride toggles the override of this section.
    $display
      ->optionsOverride($form, $form_state);
    $display
      ->submitOptionsForm($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 =& $this->displayHandlers[$form_state['display_id']];

    // optionsOverride toggles the override of this section.
    $display
      ->optionsOverride($form, $form_state);
    $display
      ->submitOptionsForm($form, $form_state);
  }
  $submit_handler = $form['#form_id'] . '_submit';
  if (function_exists($submit_handler)) {
    $submit_handler($form, $form_state);
  }
}