It is possible. What would you do is what you need for each submit button to belong to a different subform or set of fields in the main form.
This way, the submit buttons will then be placed in the namespace, and you can add them to the form.
Each submit button will have the same name. However, the full name of each submit button will still be different.
eg.
$likeSubform = new Zend_SubForm(); $dislikeSubform = new Zend_SubForm(); $like=new Zend_Form_Element_Image('vote'); $like->setImage($config->path->images."up.png") ->setValue(2); $dislike=new Zend_Form_Element_Image('vote'); $dislike->setImage($config->path->images."down.png") ->setValue(1); $likeSubform->addElement($like); $dislikeSubform->addElement($dislike); $form->addSubForm($likeSubform, 'like'); $form->addSubForm($dislikeSubform, 'dislike');
Unfortunately for you, later when you render the form, the ViewHelper decorator that comes with ZF will display the submit button using the full name. (assuming you are using this decorator, which most people do)
However, you could create your own ViewHelper decorator that overrides the default value, so instead an unqualified name will be used instead of a form element:
class My_Form_Decorator_ViewHelper extends Zend_Form_Decorator_ViewHelper { //override default render method public function render($content) { ... $name = $element->getName(); $id = $element->getName(); ... } }
source share