[TYPO3-mvc] 1:n field in request ignored when empty. How to delete childs then?

christian oettinger christian.oettinger at gmx.de
Sat Nov 27 21:06:43 CET 2010


Hi List,

we have a big object with 1:n related childs. We divide the 
creation/editing of the object in forms containing fields of the 
parent(s) and childs.

Example of one Form:
Patient (parent) Fields: Name, Age, Sex
Medcation1 (child): Name, Dose
Medication2 (child): Name, Dose
Maedication3 (child): Name, Dose

When sending the Form we manipulate the request - if all fields of a 
child are empty we delete the child form the request, so it will not be 
validated nore persisted.

This works fine as long as at least one child remains in the 
corresponding field in the request. For example if I had 3 Medications 
filled in (as above) and I delete Medication 3, it is disconnected as we 
expect. Medication 1 and 2 remain in the request and are persisted again.
If we remove all three childs though, the field in the request will be 
ignored, when building the updated object, so the childs are not 
disconnected. This happens when we remove the field as well as when we 
just empty the field or set it to 0. Only way we found is to recreate an 
empty child, but that is not what we need.

Is there a possible way to set the field in a way, that it will remove 
all childs?
Thanks in advance!

christian (oe)


More information about the TYPO3-project-typo3v4mvc mailing list