[TYPO3-dev] [Extbase] TYPO3 Backend - Create Record and 1:n relations on creation

Tizian Schmidlin st at cabag.ch
Thu Mar 12 17:34:48 CET 2015


Hello there,

I've been working lately on a backend module where the user will be able to publish changes  from the current installation to a remote destination. The culprit isn't anything related to the technical issue behind getting the systems synced or anything like this, it's more like a "basic" issue.

Until now the module only created a review record for the current page, which worked fine, A new requirement is now to be able to publish records from that page (tt_news, tt_content or anything that happens to be there).

I managed to get the whole thing posted correctly without extbase telling me that I am not allowed to try to add the field (called dbrecord) to the model when automatically mapping the posted values to the Review model by adding a hidden field with the same name to the form.

But once I've overcome this, I faced another issue, that was a bit trickier: the StorageObjectConverter does not recognize an array properly and cannot convert what I send him to an ObjectStorage object.

What my fields look like:
<input type="hidden" name="extname_modname[review][dbrecord][]" value="tt_content|123" />
<input type="hidden" name="extname_modname[review][dbrecord][]" value="tt_content|234" />
<input type="hidden" name="extname_modname[review][dbrecord][]" value="tt_content|345" />

What I get from the posted form:
array(
0 => 'tt_cntent|123',
1 => 'tt_cntent|234',
2 => 'tt_cntent|345',
)

This, it seems, cannot be processed correctly. The error is "quite" explicit: the property "0" cannot be mapped.

My question now: how should my hidden fields be named so that the StorageObjectConverter gets the data right or even better, how to I tell TYPO3 to use my DbrecordConverter instead of the ObjectStorageConvert?

I'm absolutely aware that for the obvious reason that the property "dbrecord" in my Review model is anottated with "ObjectStorage" TYPO3 will automatically try to use this converter to convert the post data to a storage object, so maybe the solution would be to Xclass the ObjectStorageConverter?

Anyway, I'm out of ideas on how to solve this properly, so any input would be welcome.

Rergards
Tizian

PS: I've now implemented a workaround and add the Dbrecord relations by hand, which works fine, but isn't the proper way of doing it, I think.



More information about the TYPO3-dev mailing list