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 @@ -2677,6 +2677,46 @@ It can be used to perform more generic operations inside of the modifier that ca
2677
2677
2678
2678
The ``query `` value will appear in the URL like ``/search?query=my+important+query&secondary-query=my+secondary+query ``.
2679
2679
2680
+ Map the parameter to path instead of query
2681
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2682
+
2683
+ .. versionadded :: 2.27
2684
+
2685
+ The ``mapPath `` option was added in LiveComponents 2.27.
2686
+
2687
+ Instead of setting the LiveProp as a query parameter, you can set it as route parameter.
2688
+ definition::
2689
+
2690
+ // ...
2691
+ use Symfony\UX\LiveComponent\Metadata\UrlMapping;
2692
+
2693
+ #[AsLiveComponent]
2694
+ class NodeModule
2695
+ {
2696
+ #[LiveProp(writable: true, url: new UrlMapping(mapPath: true))]
2697
+ public string $id = '';
2698
+
2699
+ // ...
2700
+ }
2701
+
2702
+
2703
+ The if the symfony route is defined like this::
2704
+
2705
+ // src/Controller/NodeController.php
2706
+ // ...
2707
+
2708
+ #[Route('/node/{id}', name: 'node')]
2709
+ public function node(NodeModule $nodeModule): Response
2710
+ {
2711
+ // ...
2712
+ }
2713
+
2714
+ Then the ``id `` value will appear in the URL like ``https://my.domain/node/my-node-id ``.
2715
+
2716
+ If the route parameter name is different from the LiveProp name, the ``as `` option can be used to map the LiveProp.
2717
+
2718
+ If the route parameter is not defined, the ``mapPath `` option will be ignored and the LiveProp value will fallback to a query parameter.
2719
+
2680
2720
Validating the Query Parameter Values
2681
2721
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2682
2722
You can’t perform that action at this time.
0 commit comments