[TYPO3-mvc] Editing 1:n connections - Fluid forms
christian oettinger
christian.oettinger at gmx.de
Sun Nov 7 11:34:24 CET 2010
christian oettinger schrieb:
> Hello all,
>
>
> I'm new to the List an (sorry!) quite new to Extbase/Fluid as well.
> Maybe my question ist trivial, but I did not find a solution, I hope
> someone can help.
>
> My Model has a Root "Patient". It has some Properties itself, a (1:1)
> child "FirstInfusion" and, amongst others, some (1:n) childs "Diagnosis".
>
> It's fantastically easy to make a new Object in Fluid:
>
> <f:form.textbox property="country" /><br />
> <f:form.textbox property="firstInfusion.firstInfDate" /><br />
> <f:form.textbox property="diagnosis.0.diagnosisName" /><br />
> <f:form.textbox property="diagnosis.1.diagnosisName" /><br />
>
> Editing the first two cases is also easy:
>
> <f:form.textbox property="country" /><br />
> <f:form.textbox property="firstInfusion.firstInfDate" /><br />
>
> But I don't understand how to edit the 1:n connection.
> The following will create the same Source Code as above, but the Values
> are not loaded. So two new Childs are created:
>
> <f:form.textbox property="diagnosis.0.diagnosisName" /><br />
> <f:form.textbox property="diagnosis.1.diagnosisName" /><br />
>
> The follwing loop is run, gives out the connected diagnoses - but also
> does not get the values in the Form fields.
>
> <f:for each="{patient.diagnosis}" as="oneDiagnosis">
> {oneDiagnosis.diagnosisName}
> <f:form.textbox property="oneDiagnosis.diagnosisName" />
> </f:for>
>
> I'm now looking for the right way to approach this.
> Thanks a lot fo any hint!
>
> christian (oe)
A working Approach, seems to be:
<f:for each="{patient.diagnosis}" as="oneDiagnosis">
<f:form.textbox
name="patient[diagnosis][{oneDiagnosis.uid}][diagnosisName]"
value="{oneDiagnosis.diagnosisName}"/>
<f:form.hidden
name="patient[diagnosis][{oneDiagnosis.uid}][__identity]"
value="{oneDiagnosis.uid}"/>
</f:for>
Note that you add the hidden field "__identity" (where you give the
uid), so that the values are updated not new children created.
Note also that "{oneDiagnosis.uid}" in
"patient[diagnosis][{oneDiagnosis.uid}]..." is just a way to different
between the childs. It's an identifier, like an array key not used for
persistence. You could (as far as I understand - untested) use any
iterating number.
greetings!
oe (christian)
More information about the TYPO3-project-typo3v4mvc
mailing list