Closed Nek- closed 2 months ago
But the controller is not reached at all when the component rerenders, so it needs to know which form to instantiate
That's why this method must be implemented (it's an abstract method of the ComponentWithFormTrait, used in the LiveCollectionTrait)
I'm not sure to understand.. the documentation states the following in the "ComponentWithFormTrait" section
The trait forces you to create an instantiateForm() method, which is used each time the component is rendered via AJAX. To recreate the same form as the original, we pass in the initialFormData property and set it as a LiveProp.
How would you improve things ? :)
From what I understand, the following instantiateForm is useless:
https://github.com/symfony/ux/blob/e122096cead156c2e1608976a6a69a887fd3b1a0/ux.symfony.com/src/Twig/TodoListForm.php#L32-L38
The form is actually instantiated here:
https://github.com/symfony/ux/blob/e122096cead156c2e1608976a6a69a887fd3b1a0/ux.symfony.com/src/Controller/Demo/LiveComponentDemoController.php#L50
It's pretty disturbing while reading the doc 😅