How to best handle forms for different actions and inputs that are not stored in db
This post has NOT been accepted by the mailing list yet.
This post was updated on .
I'm using Doctrine and I have all input information (including filters) specified inside entity annotations.
I was wondering what is the best way to build a form from 2 entities (relationship is unidirectional, OneToMany) and some extra inputs (not getting saved to DB - in my case they are inputs for async upload)?
I've first try to use fieldsets and I was able to get the form displayed, but I had problems getting filters from annotations. Besides that I heard some mentions that Doctrine doesn't support fieldset, so I tried another approach.
I've tried to use ComposedObject annotation but that didn't fit my needs since inputs from both entities were displayed on both sides, but I only need them on one side. Because of that I thought that there must be a better way.
I hope someone is able to push me into the right direction.
Thanks for your reaply and advice, I really appreciate it; I had a bad feeling about them, although I somehow like them at the beginning. I've also read that annotations are speed killer, is that true btw?
Based on that I've decided to remove annotations and provide that info inside forms and fieldsets instead.
I was just wondering how should I organize my forms/fieldsets for actions "add" and "edit"? Those two actions need a different input filter, that's why I created two fieldset with filters, one per each action, and I'm calling them from Form based on a parameter that is passed into the form from controller (so this way I only have 1 form). Should I rather have 1 form and 1 fieldset/filter per action? According to your words I guess I should remove filters from fieldsets (this way I could also use only 1 fieldset, since inputs are the same). Would I then add filters to form inside form rather than from fieldset?
You didn't mention form Elements, so I was wondering when we would use those?
EDIT: I have forgot to ask, would I also use fieldset for elements that are not stored in db, but the information should still be retrieved for processing? Is there any other way to get that data instead of "$request->getPost()"? Not sure how would I bind that since I have not related entity.
EDIT2: I think I figured this out. I use 1 fieldset (with inpits and filters specified) per object which contains common input information, and for each action I use a different form, where I modify/add inputs/filters so that they suit the action needs. I've also figured out that to Hydrate input values I need to add all my inputs into entity, even if inputs are not getting stored to DB. Can someone confirm this is the best way to organize forms/fieldets/inputs/filters?