Skip to content

Commit c2adbd0

Browse files
committed
rewrite doc
1 parent b838ecc commit c2adbd0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/LiveComponent/doc/index.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2684,34 +2684,34 @@ Map the parameter to path instead of query
26842684

26852685
The ``mapPath`` option was added in LiveComponents 2.28.
26862686

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``::
26892689

26902690
// ...
26912691
use Symfony\UX\LiveComponent\Metadata\UrlMapping;
26922692

26932693
#[AsLiveComponent]
2694-
class NodeModule
2694+
class SearchModule
26952695
{
26962696
#[LiveProp(writable: true, url: new UrlMapping(mapPath: true))]
2697-
public string $id = '';
2697+
public string $query = '';
26982698

26992699
// ...
27002700
}
27012701

27022702

2703-
If the symfony route is defined like this::
2703+
If the current route is defined like this::
27042704

2705-
// src/Controller/NodeController.php
2705+
// src/Controller/SearchController.php
27062706
// ...
27072707

2708-
#[Route('/node/{id}', name: 'node')]
2709-
public function node(NodeModule $nodeModule): Response
2708+
#[Route('/search/{query}')]
2709+
public function __invoke(string $query): Response
27102710
{
27112711
// ...
27122712
}
27132713

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``.
27152715

27162716
If the route parameter name is different from the LiveProp name, the ``as`` option can be used to map the ``LiveProp``.
27172717

0 commit comments

Comments
 (0)