Open
Description
Bug:
When I change payload from frontend with $this->formValues
I expect the form to be rerendered with changed data, BUT form renders as though I didn't change the payload wiht this->formValues
Description:
I have a live form, then type something (for triggering an AJAX), method instantiateForm
is called and in this method I change user's payload with $this->formValues
live prop, then I expect to see changes accrdingly my changes in $this->formValues
live prop, BUT I see data that haven't been changed.
Reproduce:
CustomFormType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('plannedAt', DateTimeType::class, ['widget' => 'choice']);
}
LiveFormClass
#[AsLiveComponent]
class LiveFormClass extends AbstractController {
#[LiveProp]
public ?Order $initialFormData = null;
protected function instantiateForm(): FormInterface
{
$this->setMinimumAvailablePlannedAtToTheFrontendPayload();
return $this->createForm(CustomFormType::class, $this->initialFormData);
}
private function setMinimumAvailablePlannedAtToTheFrontendPayload(): void
{
// CHANGE PAYLOAD DATA TO MAKE THE FORM TO BE RERENDERED DIFFERENTLY, BUT IT DOESN'T WORK
$this->formValues['plannedAt']['date']['year'] = '2000';
}
}
Maybe it's because of DateTimeType?!