Task #48964

Enable property path for nested objects (ObjectStorages) in forms

Added by Nico de Haen over 6 years ago. Updated 12 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2013-06-08
Due date:
% Done:

100%

TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Sprint Focus:

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>

ObjectAccess.patch View (1.77 KB) Nico de Haen, 2013-06-08 18:09

ObjectAccess.patch View (1.39 KB) Nico de Haen, 2013-06-08 18:13

History

#1 Updated by Nico de Haen over 6 years ago

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)

#2 Updated by Nico de Haen over 6 years ago

#3 Updated by Anja Leichsenring over 6 years ago

  • Status changed from New to Accepted

nice improvement Nico, thank you. We will have a close look in short order.

#4 Updated by Alexander Opitz about 5 years ago

  • Project changed from Fluid to TYPO3 Core
  • Category changed from Fluid to Fluid
  • TYPO3 Version set to 6.2

#5 Updated by Thomas Löffler almost 5 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?

#6 Updated by Valentin Funk almost 5 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! ;-)

#7 Updated by Gernot Ploiner over 4 years ago

vote +1

#8 Updated by Claus Due almost 4 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.

#9 Updated by Benni Mack 12 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF