Open momocode-de opened 2 days ago
Thank you for this PR @momocode-de!
I took time to look at it and one question arises: does this only change solves your DynamicFormBundle problem ? Or is this only a step ?
Right now i'm a bit hesitant here... if i(m not reading this badly, it would be a strong behaviour change:
When the second parameter $clearMissing is false, like with the "PATCH" method, the validation will only apply to the submitted fields. If you need to validate all the underlying data, add the required fields manually so that they are validated:
When submitting a form via a "PATCH" request, you may want to update only a few submitted fields. To achieve this, you may pass an optional second boolean argument to submit(). Passing false will remove any missing fields within the form object. Otherwise, the missing fields will be set to null.
https://symfony.com/doc/current/form/direct_submit.html
At least we would need some tests here, and a clear explanation of what would happen in the different scenario with some honest before/after.
Right now (and i'm very open to change my position)... i don't know... maybe you should first try to change this on your side? Because i'm not sure we should take this risk.. What do you think ?
If you have a LiveComponent for a form with dependent fields which have been implemented with the dynamic-forms bundle, it can happen that the pre-defined value disappears for fields that are displayed later. This is due to the
$clearMissing
parameter of theSymfony\Component\Form::submit
function. This parameter istrue
by default and therefore I now set it to “false” so that the values are not cleared.I can't assess whether this would have unwanted side effects. Please check it out and if you think it fits, you can merge it.