File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -2684,34 +2684,34 @@ Map the parameter to path instead of query
2684
2684
2685
2685
The ``mapPath `` option was added in LiveComponents 2.28.
2686
2686
2687
- Instead of setting the ``LiveProp `` as a query parameter, you can set it as route parameter.
2688
- definition ::
2687
+ Instead of setting the ``LiveProp `` as a query parameter, it can be set as route parameter
2688
+ by passing the `` mapPath `` option to the `` UrlMapping `` defined for the `` LiveProp `` ::
2689
2689
2690
2690
// ...
2691
2691
use Symfony\UX\LiveComponent\Metadata\UrlMapping;
2692
2692
2693
2693
#[AsLiveComponent]
2694
- class NodeModule
2694
+ class SearchModule
2695
2695
{
2696
2696
#[LiveProp(writable: true, url: new UrlMapping(mapPath: true))]
2697
- public string $id = '';
2697
+ public string $query = '';
2698
2698
2699
2699
// ...
2700
2700
}
2701
2701
2702
2702
2703
- If the symfony route is defined like this::
2703
+ If the current route is defined like this::
2704
2704
2705
- // src/Controller/NodeController .php
2705
+ // src/Controller/SearchController .php
2706
2706
// ...
2707
2707
2708
- #[Route('/node/{id}', name: 'node ')]
2709
- public function node(NodeModule $nodeModule ): Response
2708
+ #[Route('/search/{query} ')]
2709
+ public function __invoke(string $query ): Response
2710
2710
{
2711
2711
// ...
2712
2712
}
2713
2713
2714
- Then the ``id `` value will appear in the URL like ``https://my.domain/node /my-node-id ``.
2714
+ Then the ``query `` value will appear in the URL like ``https://my.domain/search /my+query+string ``.
2715
2715
2716
2716
If the route parameter name is different from the LiveProp name, the ``as `` option can be used to map the ``LiveProp ``.
2717
2717
You can’t perform that action at this time.
0 commit comments