[FLOW3-general] Creating two objects in one form

David Sporer david.sporer at googlemail.com
Wed Aug 1 11:22:19 CEST 2012


Hi Bastian,

thank you!
This was what I meant by talking about a new Model I just missed the term
DTO yesterday evening :-)

Will give it a try tonight.

Regards
David

2012/8/1 Bastian Waidelich <bastian at typo3.org>

> David Sporer wrote:
>
> Hi David,
>
>  I have two models Customer and CustomerUser and I want to create a
>> Register.html Fluid Template to create both [...]
>>
>
> The easiest solution is probably to create a so called Data Transfer
> Object [1].
> I usually store them in a folder "Dto":
>
>
> <?php
> namespace Your\Package\Domain\Dto;
>
> class CustomerAndUserDto {
>
>         /**
>          * @var \Your\Package\Domain\Model\**Customer
>          */
>         protected $customer;
>
>
>         /**
>          * @var \Your\Package\Domain\Model\**CustomerUser
>          */
>         protected $customerUser;
>
>         // getters & setters ...
>
> }
> ?>
>
>
> and then in the Fluid form:
>
>
> <f:form action="create" objectName="**newCustomerAndUser">
>   <f:form.textfield property="customer.**someCustomerProperty" />
>   <f:form.textfield property="customerUser.**someUserProperty" />
>   ...
> </f:form>
>
> (untested)
>
> The advantage is that you have mapping & validation errors in one place
> and that you can create a base validator for the Dto.
>
>
> Note: The Dto is not persisted, it must not have an @FLOW3\Entity
> annotation.
>
>
> HTH
>
>
> [1] http://en.wikipedia.org/wiki/**Data_Transfer_Object<http://en.wikipedia.org/wiki/Data_Transfer_Object>
>
> --
> 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<http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general>
>


More information about the FLOW3-general mailing list