[TYPO3-mvc] Editing 1:n connections - Fluid forms
christian oettinger
christian.oettinger at gmx.de
Mon Oct 25 23:04:05 CEST 2010
> 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)
I made some progress.
In my case I have to use value to get the value in the textbox.
I can then use property like this.
<f:for each="{patient.coMedications}" as="oneCoMedication">
<f:form.textbox
property="diagnosis.{oneDiagnosis.uid}.diagnosisName"
value="{oneDiagnosis.diagnosisName}"/><br/ ><br/ >
</f:for>
I could also use name in combination with value - instead of property,
maybe this is the more beautiful approach. This should be (untested):
name="patient[diagnosis][{oneDiagnosis.uid}][diagnosisName]"
Note that in both cases the childs are not updated. New childs are
created and connected to the parent. The old childs remain in (in my
case) the database, unconnected. The new childs have the next free uid.
For my very special case this is OK, but I'd be interested in a real
update-Solution nevertheless, so if anybody finds the time to point me.
Probably I have to extend the oersitence class?
greetings!
oe (christian)
More information about the TYPO3-project-typo3v4mvc
mailing list