Skip to content

Commit c31983f

Browse files
committed
doc
1 parent 060d2bc commit c31983f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/LiveComponent/doc/index.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,6 +2677,43 @@ It can be used to perform more generic operations inside of the modifier that ca
26772677

26782678
The ``query`` value will appear in the URL like ``/search?query=my+important+query&secondary-query=my+secondary+query``.
26792679

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+
#[Route('/node/{id}', name: 'node')]
2706+
public function node(NodeModule $nodeModule): Response
2707+
{
2708+
// ...
2709+
}
2710+
2711+
Then the ``id`` value will appear in the URL like ``https://my.domain/node/my-node-id``.
2712+
2713+
If the route parameter name is different from the LiveProp name, the ``as`` option can be used to map the LiveProp.
2714+
2715+
If the route parameter is not defined, the ``mapPath`` option will be ignored and the LiveProp value will fallback to a query parameter.
2716+
26802717
Validating the Query Parameter Values
26812718
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26822719

0 commit comments

Comments
 (0)