Skip to content
Snippets Groups Projects
Commit f678e370 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2536456 by mbovan, Berdir, Wim Leers, dawehner: Autocomplete is broken...

Issue #2536456 by mbovan, Berdir, Wim Leers, dawehner: Autocomplete is broken (its JS it not loaded)
parent e8e883f9
No related branches found
No related tags found
No related merge requests found
......@@ -128,10 +128,10 @@ public static function processAutocomplete(&$element, FormStateInterface $form_s
$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))
......
......@@ -151,6 +151,9 @@ public function testFormAutocomplete() {
$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")]');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment