Skip to content
Snippets Groups Projects
Commit cbbf2cb4 authored by Jacob Rockowitz's avatar Jacob Rockowitz Committed by jrockowitz
Browse files

Issue #2901211 by jrockowitz, thelmer: AJAX fails for new pages

parent 2f64c937
Branches
Tags 10.0.6
No related merge requests found
......@@ -339,7 +339,7 @@ class WebformNodeReferencesListController extends EntityListBuilder implements C
'#theme' => 'menu_local_action',
'#link' => [
'title' => $this->t('Add @title', ['@title' => $node_type->label()]),
'url' => Url::fromRoute('node.add', ['node_type' => $bundle], ['query' => ['webform' => $this->webform->id()]]),
'url' => Url::fromRoute('node.add', ['node_type' => $bundle], ['query' => ['webform_id' => $this->webform->id()]]),
],
];
}
......
......@@ -43,10 +43,10 @@ class WebformNodeReferencesTest extends WebformNodeTestBase {
$this->assertLink($node->label());
// Check references tab local actions.
$this->assertRaw('<li><a href="' . $base_path . 'node/add/webform?webform=contact" class="button button-action" data-drupal-link-query="{&quot;webform&quot;:&quot;contact&quot;}" data-drupal-link-system-path="node/add/webform">Add Webform</a></li>');
$this->assertRaw('<li><a href="' . $base_path . 'node/add/webform?webform_id=contact" class="button button-action" data-drupal-link-query="{&quot;webform_id&quot;:&quot;contact&quot;}" data-drupal-link-system-path="node/add/webform">Add Webform</a></li>');
// Check node with prepopulated webform.
$this->drupalGet('node/add/webform', ['query' => ['webform' => 'contact']]);
$this->drupalGet('node/add/webform', ['query' => ['webform_id' => 'contact']]);
$this->assertFieldByName('webform[0][target_id]', 'contact');
// Check node without prepopulated webform warning.
......
......@@ -133,8 +133,8 @@ function webform_node_node_prepare_form(NodeInterface $node, $operation, FormSta
}
// Populate the webform field.
$webform = \Drupal::request()->get('webform');
if ($webform && Webform::load($webform)) {
$node->$field_name->target_id = $webform;
$webform_id = \Drupal::request()->query->get('webform_id');
if ($webform_id && Webform::load($webform_id)) {
$node->$field_name->target_id = $webform_id;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment