[Autocomplete] (using without form) How to pass extra_options to stimulus controller ? #2906
Replies: 6 comments
-
Hi @matthieumastadenis , I believe the second paragraph about custom Autocomplete has been missplaced. You can pass options to a custom Autocompleter (in the meaning "not for an entity, or not with the same implementation than the one we use).. but to use extra_options it must be generated with the form system (where we generate the url / checksum). Or ... you can look at the ChecksumCalculator class to see how it's done today. But as you will see this class is marked internal, meaning it can change at any moment (passing the "extra_options" is supported, but the way it works right now must stay internal to be able to change/improve it) |
Beta Was this translation helpful? Give feedback.
-
Thanks, indeed I saw the ChecksumCalculator class and the @internal tag so I preferred to ask. For the moment I found a workaround by using a child component in which I can now use a dedicated form. But I eventually may have a similar issue in the future, and I think it would be better to avoid reimplementing ChecksumCalculator myself (especially if this is expected to change in the future). In the ideal scenario it would be great to have a twig function ( |
Beta Was this translation helpful? Give feedback.
-
Could i ask you what would be your use case here ? See what would be possible ? |
Beta Was this translation helpful? Give feedback.
-
Thank you for this issue. |
Beta Was this translation helpful? Give feedback.
-
Friendly ping? Should this still be open? I will close if I don't hear anything. |
Beta Was this translation helpful? Give feedback.
-
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm using the autocomplete component outside of a form and I need to use
extra_options
. I followed the documentation and implemented the following class:However, I cannot find how to properly pass my extra_options to the stimulus controller from twig. Unless I'm mistaken, I think the "Manually using stimulus controller" section of the documentation lacks some precision about that.
I first tried this:
...which resulted in the following error:
Then I tried this (with a custom base64_encode filter):
...which also gave me an error:
So, how can I simply pass my extra options? Do I have to manually create and include the checksum myself (if so, how exactly please?) or is there a simpler way to achieve this?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions