Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CollectionType with by_reference: false deletes all relations #29429

Closed
@Shoplifter

Description

@Shoplifter

Symfony version(s) affected: 4.1.8, not affected until 4.1.2 (I do not know about versions in between) also 4.2.0 is not affected

I use CollectionType in a form and it is configured with

'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,

When I submit the form all child entities are deleted!
The bug occurred with a OneToMany Relationship, I do not know whether ManyToMany relations are also affected or not.

Reproducer

Another thing that changed is that I used to type cast the parameter for the setter method of a OneToMany relation with ArrayCollection, which also worked out in V.4.1.2 but fails in 4.1.8. The setter is getting a PersistenCollection and throws an error. Not a big thing, but maybe that's related to the bug?

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