what is the correct way to dynamically create new Child Elements in a Fluid Form using JavaScript?
Problem: 1:n Relation (Parent/Child) using Extbase ObjectStorages: When the Parent Fluid Form is called it should be possible to add several childs (incl. properties of course!)
Dirty, partly working, Solution: I added some JS Code and added the required input elements dynamically. The "xxx" will be interated for each Child. The data will be correctly stored in the DB.
<input type="text" placeholder="First Name" name="tx_booking[newBooking][accompanyingperson][xxx][firstname]">
However, if an error occurres all child forms disappear and no f3-form-error will be shown. The reason for this, may be the redirect to originalRequest (initial form without child fields).
How can I handle this Problem without dirty tricks? Please give me shirt hint.
Following is my solution, something like yours.
Models
Controller
Template
If you have a better one, please let me know. Thanks!
Again, I will answer the question myself! The following lines are the foulest code ever but it works. I really want to know how to do this in a correct way. However, the solution is, to get the Arguments from the dynamically added JS Inputs. This is done in the errorAction and will be passed by the forward() to the initial Action, where the Errors should be appear.
I for all think, that must be a better way by using the PropertyMapper and modify the trustedProperties....
Here a short example: