diff --git a/core/lib/Drupal/Core/Render/Element/FormElement.php b/core/lib/Drupal/Core/Render/Element/FormElement.php index e4be7e1..d1d2bed 100644 --- a/core/lib/Drupal/Core/Render/Element/FormElement.php +++ b/core/lib/Drupal/Core/Render/Element/FormElement.php @@ -124,13 +124,15 @@ public static function processAutocomplete(&$element, FormStateInterface $form_s $access = $access_manager->checkNamedRoute($element['#autocomplete_route_name'], $parameters, \Drupal::currentUser(), TRUE); } - if ($access->isAllowed()) { + if ($access && $access->isAllowed()) { $element['#attributes']['class'][] = 'form-autocomplete'; $element['#attached']['library'][] = 'core/drupal.autocomplete'; // Provide a data attribute for the JavaScript behavior to bind to. $element['#attributes']['data-autocomplete-path'] = $url->getGeneratedUrl(); - CacheableMetadata::createFromObject($url)->applyTo($element); - CacheableMetadata::createFromObject($access)->applyTo($element); + CacheableMetadata::createFromRenderArray($element) + ->merge($url) + ->merge($access) + ->applyTo($element); } return $element; diff --git a/core/lib/Drupal/Core/Render/Element/RenderElement.php b/core/lib/Drupal/Core/Render/Element/RenderElement.php index 4554e82..827eafe 100644 --- a/core/lib/Drupal/Core/Render/Element/RenderElement.php +++ b/core/lib/Drupal/Core/Render/Element/RenderElement.php @@ -266,7 +266,9 @@ public static function preRenderAjaxForm($element) { // Convert \Drupal\Core\Url object to string. if (isset($settings['url']) && $settings['url'] instanceof Url) { $url = $settings['url']->setOptions($settings['options'])->toString(TRUE); - CacheableMetadata::createFromObject($url)->applyTo($element); + CacheableMetadata::createFromRenderArray($element) + ->merge($url) + ->applyTo($element); $settings['url'] = $url->getGeneratedUrl(); } else { diff --git a/core/modules/filter/src/Element/TextFormat.php b/core/modules/filter/src/Element/TextFormat.php index bb83dde..5e7d655 100644 --- a/core/modules/filter/src/Element/TextFormat.php +++ b/core/modules/filter/src/Element/TextFormat.php @@ -180,14 +180,16 @@ public static function processFormat(&$element, FormStateInterface $form_state, '#parents' => array_merge($element['#parents'], array('format')), ); - $link = \Drupal::l(t('About text formats'), Url::fromRoute('filter.tips_all', [], ['attributes' => ['target' => '_blank']]), TRUE); - $element['format']['help'] = array( + $element['format']['help'] = [ '#type' => 'container', - '#attributes' => array('class' => array('filter-help')), - '#markup' => $link->getGeneratedLink(), + 'about' => [ + '#type' => 'link', + '#title' => t('About text formats'), + '#url' => new Url('filter.tips_all', [], ['attributes' => ['target' => '_blank']]), + ], + '#attributes' => ['class' => ['filter-help']], '#weight' => 0, - ); - CacheableMetadata::createFromObject($link)->applyTo($element['format']['help']); + ]; $all_formats = filter_formats(); $format_exists = isset($all_formats[$element['#format']]);