public function ViewAddFormController::submit

Overrides Drupal\Core\Entity\EntityFormController::submit().

Overrides EntityFormController::submit

File

drupal/core/modules/views/views_ui/lib/Drupal/views_ui/ViewAddFormController.php, line 159
Contains Drupal\views_ui\ViewAddFormController.

Class

ViewAddFormController
Form controller for the Views edit form.

Namespace

Drupal\views_ui

Code

public function submit(array $form, array &$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';
    return;
  }
  $view
    ->save();
  $form_state['redirect'] = 'admin/structure/views';
  if (!empty($view
    ->get('executable')->displayHandlers['page_1'])) {
    $display = $view
      ->get('executable')->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.'));
}