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

Christian Loock chl at vkf-renzel.de
Wed Aug 13 09:41:24 CEST 2014


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?





More information about the Flow mailing list