- πΊπΈUnited States jumpsuitgreen
@Murz,
I became really hopeful when I came across this patch. I have the need to send the dynamic value from one form field as a parameter in the autocomplete route for a second field. Your patch proposes to allow this, but what syntax do I need to make it work? Can you provide an example of the'#autocomplete_route_options'
structure as well as themy_module.routing.yml
file? - Status changed to Needs review
over 1 year ago 10:59am 14 February 2023 - π¦π²Armenia murz Yerevan, Armenia
I've rebased my MR on 10.1.x branch and have added a change record with usage example: https://www.drupal.org/node/3341541 β
Please review again. - Status changed to RTBC
over 1 year ago 11:16am 14 February 2023 - ππΊHungary szato
Thank you for your work.
I'm using the MR diff with core 9.4.11 and it works. - Status changed to Needs work
over 1 year ago 12:51am 8 March 2023 - π¬π§United Kingdom alexpott πͺπΊπ
-
+++ b/core/lib/Drupal/Core/Render/Element/FormElement.php @@ -174,6 +174,7 @@ public static function validatePattern(&$element, FormStateInterface $form_state + * - #autocomplete_route_options: The options to be used in the route.
Nice to see docs added. It would be good if this pointed to the fact this is an array and some existing docs for what goes in there. Plus there is example code above that could be updated.
-
+++ b/core/lib/Drupal/Core/Render/Element/FormElement.php @@ -188,7 +189,8 @@ public static function processAutocomplete(&$element, FormStateInterface $form_s - $url = Url::fromRoute($element['#autocomplete_route_name'], $parameters)->toString(TRUE); + $options = $element['#autocomplete_route_options'] ?? []; + $url = Url::fromRoute($element['#autocomplete_route_name'], $parameters, $options)->toString(TRUE);
There's no need to assign $options - we can pass $element['#autocomplete_route_options'] to Url::fromRoute().
- We need to add test coverage - see \Drupal\form_test\FormTestAutocompleteForm for where to add some stuff and \Drupal\Tests\system\Functional\Form\ElementTest
-
- π΅π±Poland dmitry.korhov Poland, Warsaw
Rebased on latest 10.1.2 (10.1.x)
- ππΊHungary szato
Maybe it's a duplicate of an already fixed issue: Entity autocomplete widget does not pass along entity to AJAX request π Entity autocomplete widget does not pass along entity to AJAX request Fixed , and we can close this one.
- last update
about 1 year ago 29,643 pass - Status changed to Closed: duplicate
about 1 year ago 2:54pm 2 October 2023 - π¦π²Armenia murz Yerevan, Armenia
Yeah, this feature is implemented well via π Entity autocomplete widget does not pass along entity to AJAX request Fixed , so closing this issue.