1.20.x views_ui.admin.inc | views_ui_edit_view_form_submit($form, &$form_state) |
Submit handler for the configure view form.
File
- modules/
views_ui/ views_ui.admin.inc, line 2049 - Admin page callbacks for the Views UI module.
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 . '/configure/' . $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();
backdrop_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 configure it properly.
tempstore_clear('views.view', $form_state['view']->name);
}