In Zend Frameworks tutorials, I can see form processing code like
if ($request->isPost()) {
$formData = $request->getPost();
$code = $request->getParam("code");
$url = $request->getParam("url");
if ($form->isValid($formData)) {
// here goes code to determine insert/update action,
//retrive record data
//and perform relative database operation
This code repeats for many forms. I am trying to make form handling better, yet not to over-engineer it. So far I have moved this code from Controllers into Form object. But the code still diplicates for different form types.
My question is this - Should I prefer to keep form handling code duplicate or write some ProcessSubmit() Zend_Form method that will be used by all subclasses? I had experience that abstraction is not always good and sometimes you end up synching two classes that shoul've been different from beginning.
ZF examples demonstrate duplicate code, so I wonder if this duplicity is justifed (at least for small 3-4 form sites) or needs to be avoided by all means.
P.S. This task seems to be pretty common, I wonder if I do double work and there is already a ZF class for CRUD specific form handling.