Skip to content

Commit 9df1066

Browse files
committed
doc
1 parent 0c1bca4 commit 9df1066

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/LiveComponent/doc/index.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,6 +2677,45 @@ 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+
// src/Controller/NodeController.php
2706+
2707+
#[Route('/node/{id}', name: 'node')]
2708+
public function node(NodeModule $nodeModule): Response
2709+
{
2710+
// ...
2711+
}
2712+
2713+
Then the ``id`` value will appear in the URL like ``https://my.domain/node/my-node-id``.
2714+
2715+
If the route parameter name is different from the LiveProp name, the ``as`` option can be used to map the LiveProp.
2716+
2717+
If the route parameter is not defined, the ``mapPath`` option will be ignored and the LiveProp value will fallback to a query parameter.
2718+
26802719
Validating the Query Parameter Values
26812720
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26822721

0 commit comments

Comments
 (0)