Task #48964
closedEnable property path for nested objects (ObjectStorages) in forms
100%
Description
It is not possible to create a form for editing multiple objects residing in a object property of type ObjectStorage.
Example:
Model: Contact
Property: Adresses (ObjectStorage containing multiple Adress-Models)
<f:form object="{Contact}"> <for each="{Contact.Adresses}" as="adress"> <f:form.textfield property="adress.street" /> // not possible <f:form.textfield property="adress[].street" /> // not possible <f:/for> <f:/form>
Files
Updated by Nico de Haen over 11 years ago
- File ObjectAccess.patch ObjectAccess.patch added
A possible solution could be to add an index in the property path:
<f:form object="{Contact}" iteration="i"> <for each="{Contact.Adresses}" as="adress"> <f:form.textfield property="Adresses.{i.index}.street" /> <f:/for> <f:/form>
This would render a correct form, including the __identity for the object at the right level and index, but the ObjectAccessor can't map the property map since it can not handle the "index" part in the property path. I attach a patch (for Extbase) which enables the mapping for properties of type ObjectStorage/SPLObjectStorage.
(See below the patch without "use Debugger" statement)
Updated by Nico de Haen over 11 years ago
- File ObjectAccess.patch ObjectAccess.patch added
Updated by Anja Leichsenring over 11 years ago
- Status changed from New to Accepted
nice improvement Nico, thank you. We will have a close look in short order.
Updated by Alexander Opitz about 10 years ago
- Project changed from 2559 to TYPO3 Core
- Category changed from Fluid to Fluid
- TYPO3 Version set to 6.2
Updated by Thomas Löffler about 10 years ago
What's the status of this issue?
Would be great to have it minimum in 6.2!
Or is there another way to do such things yet?
Updated by Valentin Funk about 10 years ago
Thomas Löffler wrote:
What's the status of this issue?
Would be great to have it minimum in 6.2!Or is there another way to do such things yet?
That was my question! ;-)
Updated by Claus Due about 9 years ago
- Status changed from Accepted to Resolved
- % Done changed from 0 to 100
- TYPO3 Version changed from 6.2 to 7
A few comments before closing time:
- No longer applies in current TYPO3 versions (non-LTS) where ObjectAccess supports numeric indexes also for ObjectStorage
- Not "fixable" in 6.2 where support for numeric indexes would be a breaking change for some people relying on the old object-ID index names
- Suggested workaround is the intended usage: property="storageObjects.{index}.propertyname" (on non-LTS)
- Suggested syntax is not valid for "property" attribute (but is valid for "name" attribute; even required when field is multivalued).
- Only known non-destructive workaround for 6.2 is to use "name" instead of "property"
- line 165 of the suggested patch would also be a breaking change.
Closing this with "already merged for non-LTS, not mergable on LTS without breaking".
PS: sorry about this taking so long guys but I think it may be due to the general fear of touching ObjectAccess - it just has so widespread use that the slightest break could spell disaster for production sites.