Issue #3065720 by Lendude, alexpott, revati_gawas, texas-bronius: When creating a Page View in the wizard and setting a path with leading slash (/) the created View display ends up with a double-slash (//)
(cherry picked from commit 6ae9811c48
)
merge-requests/64/head
parent
ca93e60207
commit
8274945514
|
@ -176,6 +176,20 @@ class BasicTest extends WizardTestBase {
|
|||
$this->assertEqual(count($data), 1, 'Only the node of type page is exported.');
|
||||
$node = reset($data);
|
||||
$this->assertEqual($node['nid'][0]['value'], $node1->id(), 'The node of type page is exported.');
|
||||
|
||||
// Create a view with a leading slash in the path and test that is properly
|
||||
// set.
|
||||
$leading_slash_view = [];
|
||||
$leading_slash_view['label'] = $this->randomMachineName(16);
|
||||
$leading_slash_view['id'] = strtolower($this->randomMachineName(16));
|
||||
$leading_slash_view['description'] = $this->randomMachineName(16);
|
||||
$leading_slash_view['show[wizard_key]'] = 'node';
|
||||
$leading_slash_view['show[type]'] = 'page';
|
||||
$leading_slash_view['page[create]'] = 1;
|
||||
$leading_slash_view['page[title]'] = $this->randomMachineName(16);
|
||||
$leading_slash_view['page[path]'] = '/' . $this->randomMachineName(16);
|
||||
$this->drupalPostForm('admin/structure/views/add', $leading_slash_view, t('Save and edit'));
|
||||
$this->assertEquals($leading_slash_view['page[path]'], $this->cssSelect('#views-page-1-path')[0]->getText());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -164,6 +164,13 @@ class ViewAddForm extends ViewFormBase {
|
|||
$wizard_instance = $this->wizardManager->createInstance($wizard_type);
|
||||
$form_state->set('wizard', $wizard_instance->getPluginDefinition());
|
||||
$form_state->set('wizard_instance', $wizard_instance);
|
||||
|
||||
$path = &$form_state->getValue(['page', 'path']);
|
||||
if (!empty($path)) {
|
||||
// @todo https://www.drupal.org/node/2423913 Views should expect and store
|
||||
// a leading /.
|
||||
$path = ltrim($path, '/ ');
|
||||
}
|
||||
$errors = $wizard_instance->validateView($form, $form_state);
|
||||
|
||||
foreach ($errors as $display_errors) {
|
||||
|
|
Loading…
Reference in New Issue