If you use the same names in your hand-made-HTML-form as in your Zend_Form
you can simply instantiate the form on data reception:
public function processFormAction()
{
$form = new My_Form(); // this is your Zend_Form
if ($form->isValid($_POST)) {
// success!
} else {
// failure!
}
}
There is no need to use the rendering capabilities of Zend_Form
if you don't want to.
Second option is to combine your custom markup with the form's elements:
// view-script with $form being the the Zend_Form passed into the view
<form method="<?php echo $form->getMethod() ?>" action="<?php echo $form->getAction()?>">
<div id="elements">
<?php echo $form->element1->renderLabel() . $form->element1->renderViewHelper() ?>
<br />
<?php echo $form->element2->renderLabel() . $form->element2->renderViewHelper() ?>
</div>
<div id="buttons">
<?php echo $form->button1->renderViewHelper() ?>
<?php echo $form->button2->renderViewHelper() ?>
</div>
</form>
Alternatively, if you only want to filter and validate your input, you can avoid all the bloat of Zend_Form
and use Zend_Filter_Input
, which is, simply spoken, Zend_Form
without all the markup stuff. As Zend_Filter_Input
can use all the standard and custom filters and validators you're able to use with Zend_Form
, the transition should be fairly easy.