[Flow] Dynamically add element to array collection with fluid form

mario chiari ml at mariochiari.net
Fri Aug 29 18:43:43 CEST 2014


Hi

did you fix that?
How do you define createAction, I think you need to pass a Collection,
and then run over that:

public function createAction(\Doctrine\Common\Collections\Collection
$databaseUsers) { 
             	foreach($databaseUsers as $dbuser){
     			$this->dbuserRepository->add($dbuser);
			.....
}

Il giorno mer, 13/08/2014 alle 09.41 +0200, Christian Loock ha scritto:
> Hello,
> 
> I am trying to build a form with fluid, that automatically adds entries 
> to an ArrayCollection. The collection consists of entities, that shoukd 
> be dynamically created and added to the collection. Inside the form, i 
> add new fields via javascript.
> 
> The generated fluid form looks somewhat like this:
> 
> 
> 
>              <input placeholder="databaseServer.databaseuser.username" 
> class="form-control" type="text" 
> name="databaseServer[databaseUsers][0][username]" value="xxx">
>              <input placeholder="databaseServer.databaseuser.password" 
> class="form-control" type="password" 
> name="databaseServer[databaseUsers][0][password]" value="xxx">
>              <input placeholder="databaseServer.databaseuser.username" 
> class="form-control" type="text" 
> name="databaseServer[databaseUsers][1][username]" value="xxx">
>              <input placeholder="databaseServer.databaseuser.password" 
> class="form-control" type="password" 
> name="databaseServer[databaseUsers][1][password]" value="xxx">
> 
> 
> The first entry, is an existing entity. When I only try to submit the 
> form with this one in it, it will safe with no problem.
> However, when i try to add a new row to the form, so that there is an 
> entry that does not exist in the database, I get an exception:
> 
> 
>     1297759968: Exception while property mapping for target type
>     "VKF\Deployment\Domain\Model\DatabaseServer", at property path
>     "databaseUsers": It is not allowed to map property "1".
> 
> You need to use $propertyMappingConfiguration->allowProperties('1') to 
> enable mapping of this property.
> 
> 
> Does anybody know, why this happens?
> 
> 
> 
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow




More information about the Flow mailing list