function views_ui_edit_view_form_submit

Same name in other branches
  1. 7.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_view_form in includes/admin.inc
The main edit view form, which is really just a save/cancel/delete button.

File

includes/admin.inc, line 940

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;
        }
    }
    // 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) {
            $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(),
    )));
    // Make sure menu items get rebuilt as neces
    menu_rebuild();
    // Clear the views cache.
    cache_clear_all('*', 'cache_views');
    // Clear the page cache.
    cache_clear_all();
    // Remove this view from cache so we can edit it properly.
    views_object_cache_clear('view', $form_state['view']->name);
}