symfony-collection: Deleting an item from the top does not remove the corresponding Entity but the bottom one
I have a list of objects that refer to other objects
[ CourseParticipant: id1 ]->[Student A, id11]
[ CourseParticipant: id2 ]->[Student B, id22]
[ CourseParticipant: id3 ]->[Student C, id33]
after attempting to delete [ CourseParticipant: id1 ] instead of this:
[ CourseParticipant: id2 ]->[Student B, id200]
[ CourseParticipant: id3 ]->[Student C, id300]
I get :
[ CourseParticipant: id1 ]->[Student B, id200]
[ CourseParticipant: id2 ]->[Student C, id300]
The thing is that i have other entity ParticipantResults that associate to CourseParticipant and should cascade delete on deletion of CourseParticipant.
[ParticipantResults: id111 ]->[ CourseParticipant: id1 ]
[ParticipantResults: id222 ]->[ CourseParticipant: id2 ]
[ParticipantResults: id333 ]->[ CourseParticipant: id3 ]
And what happens after (attempted) deletion of [ CourseParticipant: id1 ]:
[ParticipantResults: id111 ]->[ CourseParticipant: id1 ]
[ParticipantResults: id222 ]->[ CourseParticipant: id2 ]
Now if i want to know results of Student B i get those of removed Student A. And the results of Student C are gone
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 17 (9 by maintainers)
Commits related to this issue
- Fix change of indexes while settings.preserve_names is true fix for #85 plus small syntax fixes — committed to dkop/symfony-collection by dkop 7 years ago
@DaviUchoa I have tried the ‘positionField’ approach and it did not help me.
I decided to post a distillation of my code: Students can follow learning tracks:
Many
AppUserscan be associated with aTrackvia OnToManytrackUsersproperty that is a collection ofAppUserTrackentities:In order to manage track users there is a controller:
where
TrackManageUsersTypelooks like thisI defined a
TrackUserTypeas this:All of this is initialized in
js:I hope you can do something with this!!!