Feature #7407

Edit nested properties of a domain model within a form

Added by Michael Tauer over 5 years ago. Updated almost 2 years ago.

Status:Resolved Start date:2010-04-21
Priority:Should have Due date:
Assigned To:Bastian Waidelich % Done:

100%

Category:Property
Target version:-
PHP Version: Complexity:
Has patch:No

Description

Motivation
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.

Issue
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)

History

#1 Updated by Sebastian Kurfuerst about 5 years ago

  • Status changed from New to Needs Feedback

Hey,

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 :-)

#2 Updated by Bastian Waidelich almost 2 years ago

  • Status changed from Needs Feedback to Resolved
  • Assigned To set to Bastian Waidelich
  • % Done changed from 0 to 100
  • Has patch set to No

In the meantime both scenarios are possible. (Though there are issues with validation of nested properties: #50585)

Also available in: Atom PDF