diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewPreviewForm.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewPreviewForm.php index e2d2899..2b60f58 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewPreviewForm.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewPreviewForm.php @@ -70,17 +70,21 @@ public function form(array $form, array &$form_state) { ); // Add the arguments textfield + if (!empty($form_state['values']['view_args'])) { + $preview_args = $form_state['values']['view_args']; + } + else { + $preview_args = \Drupal::request()->query->get('_preview_args'); + } $form['controls']['view_args'] = array( '#type' => 'textfield', '#title' => $this->t('Preview with contextual filters:'), '#description' => $this->t('Separate contextual filter values with a "/". For example, %example.', array('%example' => '40/12/10')), '#id' => 'preview-args', + '#default_value' => $preview_args, ); - $args = array(); - if (!empty($form_state['values']['view_args'])) { - $args = explode('/', $form_state['values']['view_args']); - } + $args = !empty($preview_args) ? explode('/', $preview_args) : array(); if (!empty($form_state['show_preview']) || !empty($form_state['input']['js'])) { $form['preview'] = array( diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php index 4ebe858..9a6550b8 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php @@ -620,7 +620,7 @@ public function renderPreview($display_id, $args = array()) { $original_path = $request->attributes->get('_system_path'); $override_path = $this->override_path; if ($args) { - $override_path .= '/' . implode('/', $args); + $request->query->set('_preview_args', implode('/', $args)); } $request->attributes->set('_system_path', $override_path); @@ -653,6 +653,7 @@ public function renderPreview($display_id, $args = array()) { // Reset variables. unset($this->override_path); $request->attributes->set('_system_path', $original_path); + $request->query->remove('_preview_args'); // Prepare the query information and statistics to show either above or // below the view preview.