-
-
Notifications
You must be signed in to change notification settings - Fork 413
[TwigComponent] How to use live_action() twig function in Twig Components tag? #3413
Copy link
Copy link
Open
Labels
Description
In a Symfony Live Component, I have something like this (simplified example):
<div {{ attributes }}>
{% set parent = this %} {# I do not know if there is a better alternative in nested twig components #}
<table>
<thead>
<tr>
{# twig:Table:Head comes from https://ux.symfony.com/toolkit/kits/shadcn/components/table, it's an anonymous Twig Component #}
<twig:Table:Head
data-action="click->live#action"
{{ live_action('sort', {sortBy: 'id'}) }}
>
{{ 'ID'|trans }}
</twig:Table:Head>
</tr>
</thead>
</table>
</div>But I have this error:
Expected attribute name when parsing the "<twig:Table:Head" syntax in components/FactorTypeSearch.html.twig at line 9.
The error comes from {{ live_action('sort', {sortBy: 'id'}) }}.
I know I can use the attributes syntax:
<twig:Table:Head
data-action="click->live#action"
data-live-action-param="sort"
data-live-sort-by-param="id"
>
{{ 'ID'|trans }}
</twig:Table:Head>But I want to use live_action because the syntax is cleaner. And since all of this comes from Symfony UX, we expect it to work naturally.
Is there a way to use {{ live_action('sort', {sortBy: 'id'}) }}? or will it be possible in the future?
Versions:
- Symfony: 8.0.7
- PHP: 8.5.3
- UX Live Component: 2.34.0
- UX Turbo: 2.34.0
- Twig: 3.24.0
Reactions are currently unavailable