[Flow] identifier gets lost in form
Mark Kuiphuis
typo3 at markyourweb.com
Sat Jun 29 09:32:29 CEST 2013
On 29/06/13 5:04 PM, Winfried Mingst wrote:
> Hi Mark,
>
> I allready tried it with the cookbook's help before. See my post from
> 17.05.13 "Exception after validation error".
> There was also the problem that identifiers were renewed in case of a
> validation error. How did you solve that?
>
> On IRC I was told that if there is a relation between models it should work
> without a dto also.
>
> Did you define relations between your models (1:1,1:n,...)?
> Here you can find my samplecode:
> http://github.com/regioadmin/WL.Test/blob/912f1a2573bac3eabf848f98eb54a33689
> 5307cf/Classes/WL/Test/Controller/MasterController.php
>
> Regards
> Winfried
>
> -----Ursprüngliche Nachricht-----
> Von: flow-bounces at lists.typo3.org [mailto:flow-bounces at lists.typo3.org] Im
> Auftrag von Mark Kuiphuis
> Gesendet: Samstag, 29. Juni 2013 06:32
> An: flow at lists.typo3.org
> Betreff: Re: [Flow] identifier gets lost in form
>
> On 29/06/13 12:12 AM, Winfried Mingst wrote:
>> Hi Flowx,
>>
>> I try to edit properties of two models in one form desperately.
>> There is a "master" and "detail" model/entity (1:1 unidirectional
>> relation, "detail" holds foreign key @ORM OneToOne(
>> cascade={"persist","remove"}))
>>
>> Source code of edit form shows identifiers of both models initialy:
>>
>> <input type="hidden" name="detail[__identity]" value="20390230..." />
>> <input type="hidden" name="detail[master][__identity]"
>> value="91a3aa0..." />
>>
>>
>> BUT if the form is reloaded in case of a validation error, the 2nd
>> hidden field gets lost!
>> The result is a duplicate dataset in table master when the form is
>> resubmitted.
>>
>> here is my Controller
>>
> https://github.com/regioadmin/WL.Test/blob/master/Classes/WL/Test/Controller
> /DetailController.php
>>
>> here is my edit form
>>
> https://github.com/regioadmin/WL.Test/blob/master/Resources/Private/Template
> s/Detail/Edit.html
>>
>>
>>
>> What's wrong? Do I need some additional subPropertyMapping config?
>>
>> thx
>>
>> Winfried
>
> Hi Winfried,
>
> Maybe this is of any help you. At least it helped me creating and
> updating 2 and 3 objects in one Fluid form:
>
> http://wiki.typo3.org/Flow_Cookbook#Create_multiple_objects_with_one_Fluid_f
> orm
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>
Line 22 of your Masterdetaildto says:
* @return \WL\Komsis\Domain\Model\Master
That should be:
* @return \WL\Test\Domain\Model\Master
Furthermore looks my newAction quite a bit different. This is where I
create new objects of the two models I would like to store via this one
form (I have used it to create a branch of a company with the first
address (in my scenario I can have a postal address and a physical
address for every branch)
So my newAction looks like this:
protected function newAction() {
// Create object Branch
$branch = new \My\Package\Domain\Model\Branch();
$branchAddress = new \My\Package\Domain\Model\BranchAddress();
// Construct the DTO by passing in the two new objects
$branchAndAddress = new
\MarkYourWeb\PlumbersUnionQld\Domain\Dto\BranchAndAddress($branch,
$branchAddress);
Then the form element does look like this: (also different than yours as
you don't have the object="{branchAndAddress}" attribute)
<f:form action="create" name="branchAndAddress" id="branchAndAddress"
object="{branchAndAddress}">
...
...
</f:form>
I believe that because of this missing object attribute, your generated
input fields look like:
<input type="text" name="master[name]" ..... />
While in fact it should look like:
<input type="text" name="newMasterdetaildto[master][name]" ..... />
I'm not saying that this will immediately solve this problem, but it
might give you a little push in the right direction :-)
Cheers, Mark
More information about the Flow
mailing list