You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my QuantityControl component I need to adjust the value live property based on min and max live properties:
<twig:QuantityControlmax="3" />
I have this following problem:
Calling adjustValue from a live action works, I can access max value
When adjustValue is called by the framework using the onUpdated hook... max is null
<?phpnamespaceApp\Twig\Components;
useSymfony\UX\LiveComponent\Attribute\AsLiveComponent;
useSymfony\UX\LiveComponent\Attribute\LiveAction;
useSymfony\UX\LiveComponent\Attribute\LiveProp;
useSymfony\UX\LiveComponent\ComponentToolsTrait;
useSymfony\UX\LiveComponent\DefaultActionTrait;
useSymfony\UX\TwigComponent\Attribute\ExposeInTemplate;
#[AsLiveComponent]
classQuantityControl
{
useDefaultActionTrait;
#[LiveProp]
publicint$min = 0;
#[LiveProp()]
public ?int$max = null;
#[LiveProp]
publicint$step = 1;
#[LiveProp(writable: true, onUpdated: 'adjustValue')]
public ?int$value = 0;
#[LiveAction]
publicfunctionup()
{
$this->value += $this->step;
// $this->adjustValue(); // When called from up(), max property is not null
}
#[LiveAction]
publicfunctiondown()
{
$this->value -= $this->step;
// $this->adjustValue(); // When called from down(), max property is not null
}
publicfunctionadjustValue(): void
{
// Here max property is null, despite being passed
dd($this->max);
}
}
This is something @weaverryan started to work. Originnaly the actions were not designed to be called from PHP, but this is somethings that has been asked several time, so he started to digg in this question.
Currently (and probably until 2.18) you're right: those hooks are only called once, during dehydration.
In my
QuantityControl
component I need to adjust thevalue
live property based onmin
andmax
live properties:I have this following problem:
adjustValue
from a live action works, I can accessmax
valueadjustValue
is called by the framework using theonUpdated
hook...max
is nullThe component twig if matters:
The text was updated successfully, but these errors were encountered: