Same name and namespace in other branches
  1. 6.x-3.x includes/admin.inc \views_ui_edit_view_form_submit()

Submit handler for the edit view form.

1 string reference to 'views_ui_edit_view_form_submit'
views_ui_edit_form in includes/admin.inc
Form builder callback for editing a View.

File

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

Code

function views_ui_edit_view_form_submit($form, &$form_state) {

  // Go through and remove displayed scheduled for removal.
  foreach ($form_state['view']->display as $id => $display) {
    if (!empty($display->deleted)) {
      unset($form_state['view']->display[$id]);
    }
  }

  // Rename display ids if needed.
  foreach ($form_state['view']->display as $id => $display) {
    if (!empty($display->new_id)) {
      $form_state['view']->display[$id]->id = $display->new_id;

      // Redirect the user to the renamed display to be sure that the page
      // itself exists and doesn't throw errors.
      $form_state['redirect'] = 'admin/structure/views/view/' . $form_state['view']->name . '/edit/' . $display->new_id;
    }
  }

  // Direct the user to the right url, if the path of the display has changed.
  if (!empty($_GET['destination'])) {
    $destination = $_GET['destination'];

    // Find out the first display which has a changed path and redirect to this
    // URL.
    $old_view = views_get_view($form_state['view']->name);
    foreach ($old_view->display as $id => $display) {

      // Only check for displays with a path.
      if (!isset($display->display_options['path'])) {
        continue;
      }
      $old_path = $display->display_options['path'];
      if ($display->display_plugin == 'page' && $old_path == $destination && $old_path != $form_state['view']->display[$id]->display_options['path']) {
        $destination = $form_state['view']->display[$id]->display_options['path'];
        unset($_GET['destination']);
      }
    }
    $form_state['redirect'] = $destination;
  }
  $form_state['view']
    ->save();
  drupal_set_message(t('The view %name has been saved.', array(
    '%name' => $form_state['view']
      ->get_human_name(),
  )));

  // Remove this view from cache so we can edit it properly.
  ctools_object_cache_clear('view', $form_state['view']->name);
}