2012/9/18 Ralf Eggert <[email protected]> > Interesting stuff. I am thinking about this, but the rules of thumb > might not fit on every case I think. > > Here is an example controller I use for managing users by an admin: > > --------------------------------------------------------------------- > class AdminController > { > public function indexAction() > { > // uses select form > } > > public function addAction() > { > // uses create form > } > > public function updateAction() > { > // uses update form > } > > public function deleteAction() > { > // uses delete form > } > } > --------------------------------------------------------------------- > > These are 4 actions and 4 forms. Would you really split this up in more > than one controller? >
Usually I use 1 controller per entity. Most of the time I have an Index (list), View and CRUD (Create, Update, Delete) actions. For the View and Delete, a route param for the id is required. This also means I can delete the entity "Foo" without a form. You just POST to /my/foo/delete/12. If you want to have a CSRF check, use the FooForm with only the CSRF element in your validation group. The same holds for create and update: they exactly use the same form FooForm. The create is a POST to /my/foo/create and the update a POST to /my/foo/update/12. I see no need in using different forms for every action here :) -- Jurian Sluiman
