Edit nested properties of a domain model within a form
This should give some background information and introduce the issue for a special example:
I am planning to build a flexible (and more or less complex) web application based on FLOW3. Therefore I want to localize titles and descriptions for different objects. Because I don't want to implement some properties like titleDE, titleEN, titleES, ... for all the domain models my idea was to define a class named LocalizedString that contains a language key and a string. Every domain model that need different translations for a title or description defines this title/description property as an array of LocalizedString objects. I guess this design decision is comprehensible and I hope I'm not the only one who will do it that way. Now at this point I can't see any solution to edit multiple title strings wihtin a form for the domain model because every single localized title string is no longer a property of the model itself but a property of a nested array of LocalizedString instances.
I think it would be very helpful for the framework to edit also nested properties wihtin forms. This could be defined in the templates somethink like this:
a) for nested property objects
<f:form.textbox property="adress:street:number" /> <!-- The property "adress" contains a nested property "street" that itself contains a "name" and a "number" property.-->
b) for nested arrays
<f:form.textbox property="titles(0):string" /> <f:form.hidden property="titles(0):language" value="de-DE" /> <f:form.textbox property="titles(1):string" /> <f:form.hidden property="titles(1):language" value="en-GB" /> <!-- The numbers 0 and 1 are replaceable keys that only define properties of the same nested item -->
Currently I am doing a workaround for the PropertyMapper that will now parse nested properties as well but this is possibly not the best and smartest way to solve the problem. I also suppose that there are more places that have to be changed (possibly the persistance update function). ...and I don't know if all this will work in the end.
Please give a reply if anyone has an idea of solving the problem. I think a good solution could be interesting for many other applications too (e.g. to edit multiple comments of one post, to edit properties of multiple items of a booking order, to encapsulate items of an adress as single class and edit the street and city information directly within the form of a contact)
Updated by Sebastian Kurfuerst about 11 years ago
- Status changed from New to Needs Feedback
I just stumbled over this issue, and partly this is already possible.
concerning case a), just use the dot syntax you know from fluid:
<f:form.textbox property="address.street.number" />, then it will just work.
b) is not easily possible right now, as a ViewHelper for that is still missing.
Please check if a) works :-)