[FLOW3-general] Persist a TYPO3.Form to my own domain model

Bastian Waidelich bastian at typo3.org
Fri Jul 27 18:12:49 CEST 2012


Peter Grassberger wrote:

Hi Peter,

> thank you for this example, it helped me a lot!

Thanks for the feedback ;)

> I'm trying to add an image upload like this:
>
>      protected function createFormElements(\TYPO3\Form\Core\Model\AbstractSection $section) {
>          // …
>
>          $image = $section->createElement($this->objectPrefix . '.image', 'TYPO3.Form:ImageUpload');
>          $image->setLabel('Image');
>
>          // …
>      }
>
> but I get:
> #1297759968: Exception while property mapping for target type "TYPO3\Media\Domain\Model\Image" [...]


You could try to add

$propertyMappingConfiguration = 
$this->formDefinition->getProcessingRule($this->objectPrefix)->getPropertyMappingConfiguration();
$resourcePropertyMappingConfiguration = 
$propertyMappingConfiguration->forProperty('image.resource')

$resourcePropertyMappingConfiguration 
->setTypeConverterOption('TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter', 
\TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, 
TRUE);

and/or


$resourcePropertyMappingConfiguration 
->setTypeConverterOption('TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter', 
\TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, 
TRUE);

(untested)

Of course this is just a preliminary solution. In the long run the form 
factory should disable the extended property mapping check (as the form 
factories have their own security mechanism built in).

HTH

-- 
Bastian Waidelich
TYPO3 Core Team Member

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the FLOW3-general mailing list