Skip to content

[LiveComponent] (Dynamic Form) Default values disappear for dynamically added fields #2369

Open
@momocode-de

Description

@momocode-de

I have a LiveComponent for a form. This form has dependent fields which have been implemented with the dynamic-forms bundle. I have a situation where I have select fields that are only added when certain other fields have been filled in. These select fields should have a preselected value. To do this, I set the value in the corresponding fields in the object for the initial form values. The problem is that these values disappear when the fields are added and therefore no value is preselected in the fields. There is already an issue for this in the dynamic-forms bundle. I have now debugged it and found out what the problem is. This is due to the $clearMissing parameter of the Symfony\Component\Form::submit function. This parameter is true by default. The function is called here without the 2nd parameter. If I set the 2nd parameter to false, the problem is solved. I could create a PR for it now, but unfortunately I can't assess whether this would have unwanted side effects. Can anyone say? Is it ok to set the $clearMissing parameter to false in the ComponentWithFormTrait on submit?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions