diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteTagsWidget.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteTagsWidget.php index 6d46c2f..20cb005 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteTagsWidget.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteTagsWidget.php @@ -24,7 +24,7 @@ * settings = { * "match_operator" = "CONTAINS", * "size" = 60, - * "autocomplete_path" = "entity_reference/autocomplete/tags", + * "autocomplete_type" = "tags", * "placeholder" = "" * }, * multiple_values = TRUE diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidget.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidget.php index fb2b575..ef17efa 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidget.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidget.php @@ -30,7 +30,7 @@ * settings = { * "match_operator" = "CONTAINS", * "size" = 60, - * "autocomplete_path" = "entity_reference/autocomplete/single", + * "autocomplete_type" = "single", * "placeholder" = "" * } * ) diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php index 3587046..9fbd937 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php @@ -74,23 +74,24 @@ public function formElement(FieldInterface $items, $delta, array $element, $lang global $user; $entity = $element['#entity']; - // Prepare the autocomplete path. - $autocomplete_path = $this->getSetting('autocomplete_path'); - $autocomplete_path .= '/' . $this->fieldDefinition->getFieldName() . '/' . $entity->entityType() . '/' . $entity->bundle() . '/'; + // Prepare the autocomplete route parameters. + $autocomplete_route_parameters = array( + 'type' => $this->getSetting('autocomplete_type'), + 'field_name' => $this->fieldDefinition->getFieldName(), + 'entity_type' => $entity->entityType(), + 'bundle_name' => $entity->bundle(), + ); - // Use as a placeholder in the URL when we don't have an entity. - // Most web servers collapse two consecutive slashes. - $id = 'NULL'; if ($entity && $entity_id = $entity->id()) { - $id = $entity_id; + $autocomplete_route_parameters['entity_id'] = $entity_id; } - $autocomplete_path .= $id; $element += array( '#type' => 'textfield', '#maxlength' => 1024, '#default_value' => implode(', ', $this->getLabels($items)), - '#autocomplete_path' => $autocomplete_path, + '#autocomplete_route_name' => 'entity_reference.autocomplete', + '#autocomplete_route_parameters' => $autocomplete_route_parameters, '#size' => $this->getSetting('size'), '#placeholder' => $this->getSetting('placeholder'), '#element_validate' => array(array($this, 'elementValidate')),