[FLOW3-general] Creating two objects in one form
Winfried Holler
mailtestler at web.de
Wed Dec 19 10:41:35 CET 2012
Hi David,
with your help I managed now to create two objects in one form. THX !!!
For everybody who interested in, here is an example: http://snipt.org/yhwd2
Regards
Winfried
In my example data of inputfields are stored now in the corresponding
tables. But the foreign key is not set.
implemted a simple example . In the form you can create a pair of names
(parent, child)
When I create a
"David Sporer" <david.sporer at gmail.com> schrieb im Newsbeitrag
news:mailman.11795.1355748377.598.flow3-general at lists.typo3.org...
> Hi Winfried,
>
> I don't have an example right now. Have you tried the one from the TYPO3
> Flow Cookbook?
> http://wiki.typo3.org/FLOW3_Cookbook#Create_multiple_objects_with_one_Fluid_form
> This is basically all you need to do
> -create a Model (without the entity Annotation) that contains all models
> you want to create objects for.
> -use this model in a fluid form
> -persist the newly created object
>
> the last one is not shown in the cookbook example but it's fairly easy:
> $modelOne = $newlyCreatedModel->getModelOne();
> $this->modelOneRepository->add($modelOne);
>
> $modelTwo = $newlyCreatedModel->getModelTwo();
> $this->modelTwoRepository->add($modelTwo);
>
> Regards
> David
>
>
> 2012/12/17 Winfried Holler <mailtestler at web.de>
>
>> Hi David,
>>
>> I'm stuck with the same problem trying to implement such a dto. Where
>> can
>> I
>> find a example? Can you post
>> sources of a working dto, controller, template...?
>>
>> Regards
>>
>> Winfried
>>
>> "David Sporer" <david.sporer at googlemail.com> schrieb im Newsbeitrag
>> news:mailman.879.1343812941.626.flow3-general at lists.typo3.org...
>> > 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>
>> >>
>>
>>
>> _______________________________________________
>> 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