Skip to content

Commit 314ca71

Browse files
committed
minor #2610 [LiveComponent] Document how to pass a value to an event listener from Twig. (Artusamak)
This PR was merged into the 2.x branch. Discussion ---------- [LiveComponent] Document how to pass a value to an event listener from Twig. | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Issues | - | License | MIT The document is missing an important use case related to Event dispatching and listeners. There is no documentation about how to pass data from a Twig template to an event listener method within the component. This PR adds an example. Commits ------- 2180eca Document how to pass a value to an event listener from Twig.
2 parents 8a11743 + 2180eca commit 314ca71

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/LiveComponent/doc/index.rst

+10
Original file line numberDiff line numberDiff line change
@@ -2776,6 +2776,16 @@ You can also pass extra (scalar) data to the listeners::
27762776
]);
27772777
}
27782778

2779+
From a Twig template:
2780+
2781+
.. code-block:: html+twig
2782+
2783+
<button
2784+
data-action="live#emit"
2785+
data-live-event-param="productAdded"
2786+
data-live-product-param="123"
2787+
>
2788+
27792789
In your listeners, you can access this by adding a matching argument
27802790
name with ``#[LiveArg]`` in front::
27812791

0 commit comments

Comments
 (0)