summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-07-23 12:01:50 (GMT)
committerAlex Pott2015-07-23 12:01:50 (GMT)
commitf678e370ff269267d3eca2d9307b46d2d41db7ee (patch)
treedaa8def8122bfa9295a8144c1e860ed92eddba5f
parente8e883f9c855cd419ac045c30d6ccb7f20c9993e (diff)
Issue #2536456 by mbovan, Berdir, Wim Leers, dawehner: Autocomplete is broken (its JS it not loaded)
-rw-r--r--core/lib/Drupal/Core/Render/Element/FormElement.php4
-rw-r--r--core/modules/system/src/Tests/Form/ElementTest.php3
2 files changed, 5 insertions, 2 deletions
diff --git a/core/lib/Drupal/Core/Render/Element/FormElement.php b/core/lib/Drupal/Core/Render/Element/FormElement.php
index ab13289..173a55c 100644
--- a/core/lib/Drupal/Core/Render/Element/FormElement.php
+++ b/core/lib/Drupal/Core/Render/Element/FormElement.php
@@ -128,10 +128,10 @@ abstract class FormElement extends RenderElement implements FormElementInterface
$metadata = BubbleableMetadata::createFromRenderArray($element);
if ($access->isAllowed()) {
$element['#attributes']['class'][] = 'form-autocomplete';
- $element['#attached']['library'][] = 'core/drupal.autocomplete';
+ $metadata->addAttachments(['library' => ['core/drupal.autocomplete']]);
// Provide a data attribute for the JavaScript behavior to bind to.
$element['#attributes']['data-autocomplete-path'] = $url->getGeneratedUrl();
- $metadata->merge($url);
+ $metadata = $metadata->merge($url);
}
$metadata
->merge(BubbleableMetadata::createFromObject($access))
diff --git a/core/modules/system/src/Tests/Form/ElementTest.php b/core/modules/system/src/Tests/Form/ElementTest.php
index d7085dd..6555a4f 100644
--- a/core/modules/system/src/Tests/Form/ElementTest.php
+++ b/core/modules/system/src/Tests/Form/ElementTest.php
@@ -151,6 +151,9 @@ class ElementTest extends WebTestBase {
$this->drupalLogin($user);
$this->drupalGet('form-test/autocomplete');
+ // Make sure that the autocomplete library is added.
+ $this->assertRaw('core/misc/autocomplete.js');
+
$result = $this->xpath('//input[@id="edit-autocomplete-1" and contains(@data-autocomplete-path, "form-test/autocomplete-1")]');
$this->assertEqual(count($result), 1, 'Ensure that the user does have access to the autocompletion');
$result = $this->xpath('//input[@id="edit-autocomplete-2" and contains(@data-autocomplete-path, "form-test/autocomplete-2/value")]');