Commit f678e370 authored by alexpott's avatar alexpott

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
......@@ -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")]');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment