You are here

function views_ui_add_form_save_submit in Views (for Drupal 7) 8.3

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

Process the add view form, 'save'.

1 string reference to 'views_ui_add_form_save_submit'
ViewUI::buildAddForm in views_ui/lib/Drupal/views_ui/ViewUI.php

File

views_ui/admin.inc, line 325
Provides the Views' administrative interface.

Code

function views_ui_add_form_save_submit($form, &$form_state) {
  try {
    $view = $form_state['wizard_instance']
      ->create_view($form, $form_state);
  } catch (WizardException $e) {
    drupal_set_message($e
      ->getMessage(), 'error');
    $form_state['redirect'] = 'admin/structure/views';
  }
  $view
    ->save();
  $form_state['redirect'] = 'admin/structure/views';
  if (!empty($view->displayHandlers['page_1'])) {
    $display = $view->displayHandlers['page_1'];
    if ($display
      ->hasPath()) {
      $one_path = $display
        ->getOption('path');
      if (strpos($one_path, '%') === FALSE) {
        $form_state['redirect'] = $one_path;

        // PATH TO THE VIEW IF IT HAS ONE
        return;
      }
    }
  }
  drupal_set_message(t('Your view was saved. You may edit it from the list below.'));
}