File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -2737,6 +2737,46 @@ It can be used to perform more generic operations inside of the modifier that ca
2737
2737
2738
2738
The ``query `` value will appear in the URL like ``/search?query=my+important+query&secondary-query=my+secondary+query ``.
2739
2739
2740
+ Map the parameter to path instead of query
2741
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2742
+
2743
+ .. versionadded :: 2.29
2744
+
2745
+ The ``mapPath `` option was added in LiveComponents 2.29.
2746
+
2747
+ Instead of setting the ``LiveProp `` as a query parameter, it can be set as route parameter
2748
+ by passing the ``mapPath `` option to the ``UrlMapping `` defined for the ``LiveProp ``::
2749
+
2750
+ // ...
2751
+ use Symfony\UX\LiveComponent\Metadata\UrlMapping;
2752
+
2753
+ #[AsLiveComponent]
2754
+ class SearchModule
2755
+ {
2756
+ #[LiveProp(writable: true, url: new UrlMapping(mapPath: true))]
2757
+ public string $query = '';
2758
+
2759
+ // ...
2760
+ }
2761
+
2762
+
2763
+ If the current route is defined like this::
2764
+
2765
+ // src/Controller/SearchController.php
2766
+ // ...
2767
+
2768
+ #[Route('/search/{query}')]
2769
+ public function __invoke(string $query): Response
2770
+ {
2771
+ // ...
2772
+ }
2773
+
2774
+ Then the ``query `` value will appear in the URL like ``https://my.domain/search/my+query+string ``.
2775
+
2776
+ If the route parameter name is different from the LiveProp name, the ``as `` option can be used to map the ``LiveProp ``.
2777
+
2778
+ If the route parameter is not defined, the ``mapPath `` option will be ignored and the LiveProp value will fallback to a query parameter.
2779
+
2740
2780
Validating the Query Parameter Values
2741
2781
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2742
2782
You can’t perform that action at this time.
0 commit comments