function ViewEditForm::submitDuplicateDisplayAsType
Same name in other branches
- 9 core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::submitDuplicateDisplayAsType()
- 10 core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::submitDuplicateDisplayAsType()
- 11.x core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::submitDuplicateDisplayAsType()
Submit handler to Duplicate a display as another display type.
File
-
core/
modules/ views_ui/ src/ ViewEditForm.php, line 888
Class
- ViewEditForm
- Form controller for the Views edit form.
Namespace
Drupal\views_uiCode
public function submitDuplicateDisplayAsType($form, FormStateInterface $form_state) {
/** @var \Drupal\views\ViewEntityInterface $view */
$view = $this->entity;
$display_id = $this->displayID;
// Create the new display.
$parents = $form_state->getTriggeringElement()['#parents'];
$display_type = array_pop($parents);
$new_display_id = $view->duplicateDisplayAsType($display_id, $display_type);
// By setting the current display the changed marker will appear on the new
// display.
$view->getExecutable()->current_display = $new_display_id;
$view->cacheSet();
// Redirect to the new display's edit page.
$form_state->setRedirect('entity.view.edit_display_form', [
'view' => $view->id(),
'display_id' => $new_display_id,
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.