[TYPO3-dev] Extbase fluid form with model object with relations

Marcel Utz utz.marcel at googlemail.com
Thu Jan 2 12:03:58 CET 2014


Dear guys,

I created a TYPO3 extension with the extension builder with one model object ("customer"), which has one 1:1 relation to another object ("card") and one 1:n relation to another object ("address"). I just want to create and edit this model object with its relations in one form and validate all.

- customer
      - card (model object: card, 1:1, fields: number)
      - addresses (model object: address, 1:n, fields: firstName, lastName, ...)

The following steps are done in default new/create action.

For the 1:1 relation I added for property "number" (type string) the following field to the form.
<f:form.textfield property="card.number" />
When I submit the form I got the following error.

#1309255651: Invalid type encountered: '' (More information)
InvalidArgumentException thrown in file
/html/beta/typo3/sysext/extbase/Classes/Service/TypeHandlingService.php in line 64.

/html/beta/typo3/sysext/extbase/Classes/Service/TypeHandlingService.php: function parseType(). I debugged and found that there is no type for the field card. 


1:n relation field in form:
<f:form.textfield property="addresses.0.firstName" />
<f:form.textfield property="addresses.0.lastName" />

Debugging von model "customer" shows this (field "firstName" filled with "first" and field "lastName" filled with "last" and submitted):
..
addresses => Tx_Extbase_Persistence_ObjectStorageprototypemodified object (1 items)
      000000003ad617180000000018ca0c80 => Tx_Customer_Domain_Model_Addressprototypetransient entity
            type => NULL
            salutation => NULL
            firstName => 'first' (5 chars)
            lastName => 'last' (4 chars)
            street => NULL
            additional => NULL
            zip => NULL
            city => NULL
            country => NULL
            uid => NULL
            _localizedUid => NULL
            _languageUid => NULL
            pid => NULL
..
The fields firstName and lastName are saved correctly to the domain model as a relation and if form is submitted correctly, they are saved correctly in the database. The problem is: those two fields are not validated (both have @validate NotEmpty in Model object address) and when form is submitted and there is an error, there is no value in the field anymore. I just tired as an attribute value="{customer.addresses.0.firstName}". But this shouldn't work because of this long number in the result (000000003ad617180000000018ca0c80).

I'm working with TYPO3 4.7.2 and 6.1.7, errors in both versions.

I still spent a lot of days to get rid of my problem, but got no idea anymore.


What do I have to do to implement a model object with relations in a fluid form correctly?


Best wishes,

Marcel



More information about the TYPO3-dev mailing list