Open nklth opened 1 year ago
Bump
Hi i found a workaround: use the PostMount and unset the initialFormData: The prefilled form works fine:
`
public function postMount(): void
{
$this->initialFormData = [];
}
protected function instantiateForm(): FormInterface
{
return $this->createForm(YourFormType::class, $this->initialFormData);
}
`
Hey, thanks for your report! There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?
Friendly ping? Should this still be open? I will close if I don't hear anything.
Hey,
I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!
Hi,
I am currently trying out Symfony Forms and Live components to reduce the need for Javascript. The first try outs went quite well and I would love to use this in the future!
But I have found a bug which seemed random at first (my form is a little bit more complicated using the choices type to add additional fields to the form), but I can now reproduce it in a simple form:
Requirements:
I have a form with a choice type and 3 choices, and an additional text field with a NotBlank validation.
Steps to reproduce:
Everything works fine, before the submit is done.
What I have found in the Chrome inspector is: After the first step the data-live-data-value attribute looks like this:
{"test":{"choices":["zero","one"],"name":""},"isValidated":false,"validatedFields":["test.choices"]}
==> The choices field is an array, as expectedAfter step 3 it looks like this:
"{"test":{"choices":{"1":"one"},"name":""},"isValidated":true,"validatedFields":[]}
==> The choices field now is a json valueAnd finally after step 4 it looks like this:
{"test":{"choices":"zero","name":""},"isValidated":true,"validatedFields":[]}
==> The choices field now has a string valueAnd this string value seems to be submitted to the form which triggers the invalid value error.
I have created a reproducer with this simple form here if needed: https://github.com/nklth/live-component-form-choices