How to best handle forms for different actions and inputs that are not stored in db

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to best handle forms for different actions and inputs that are not stored in db

Tad3j
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!
Reply | Threaded
Open this post in threaded view
|

Re: Form from 2 entities and extra inputs

Tad3j
I think I should follow this example, but when I did I had problems with InputFilter, since I have them stored inside entities/annotations.

I'll try to go through that example again and I'll see what I end up with; I guess there must be a way to also import InputFilter from annotations that way (via Fieldset).
Reply | Threaded
Open this post in threaded view
|

Re: Form from 2 entities and extra inputs

Stefano Torresi
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Form from 2 entities and extra inputs

Tad3j
This post was updated on .
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?