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

Peter Grassberger p.grassberger at websafari.eu
Fri Jul 27 17:01:51 CEST 2012


Hi Bastian,

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

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", at property path "": It is not allowed to map property "resource". You need to use $propertyMappingConfiguration->allowProperties('resource') to enable mapping of this property.

I tried several things but I always get similar exceptions.. :(

Peter Grassberger


Am 17.07.2012 um 17:44 schrieb Bastian Waidelich:

> Søren Malling wrote:
> 
> Hi Søren
> 
>> Is it possible, using a form generated with TYPO3.Form, to map the
>> submitted data to a argument in the controller->action which the
>> finishers redirects to?
>> 
>> Or, in some other way persist the submitted data as a object?
> 
> Finally I got round to this, sorry for the delay.
> 
> Ok, here's a slightly reduced version of an "AbstractModelFormFactory":
> 
> https://gist.github.com/3130147
> 
> I've put this into the TYPO3.Form namespace as I would like something like this to be part of the package. But this is not yet fine tuned enough and lacks documentation & tests. So feel free to add this to your own package (don't forget to adjust the namespace).
> 
> The factory leaves the creation of form elements to you, but it transparently adds default values and validators from your domain model.
> 
> The provided example shows how you can easily create create/edit forms with one form factory now.
> 
> 
> Let me know if something is not clear or if you have some ideas on how to improve this.
> 
> Best,
> 
> -- 
> Bastian Waidelich
> TYPO3 Core Team Member
> 
> TYPO3 .... inspiring people to share!
> Get involved: typo3.org
> 
> 
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general



More information about the FLOW3-general mailing list