I going to set up some large forms with up to 100 fields.
Now my question is if there is some best practise about handling such forms.
Especially:
- Entity relations
- Form object it self
Does somebody have experience about such tasks?
Should I put all together in one entity, one form, structured with jQuery in subforms or should I group the attributes to arrays as much as possible?
Regards,
Bodo
Whereas official documentation show many examples of forms directly linked to entities, I think this is not the best approach. In rare case it’s good, when your form has exactly the same fields as your entity.
Your form must represent what you get in the browser, so only html inputs/textearea/select. I usually create a formData class, like an entity, that holds validation constraints and has the same structure as the form.
You have to initialize this formData object with your persisted datas before loading the form, and after submission, you update your entities with your formData object…