Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend two submit buttons same name

I built a form class extending zend_form.I have two submitting buttons :

$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);

I'd want to have two submit buttons with same name and different value so that I can later access the value of the submitted one by a switch statement in the controller:

$submit = $this->_request->getPost('vote');

 switch($submit) {
 case 'one':
 // button one was pressed
 break;
 case 'two':
}

}

But If I do set those with the same name the last one is overriding the first so only one button is output.

With file elements theres a method setMultifile() that does the trick.

what should I do here?

thanks

Luca

like image 735
luca Avatar asked Jun 02 '11 08:06

luca


1 Answers

You might try using array notation for the images.

like image 96
Glen Solsberry Avatar answered Oct 19 '22 01:10

Glen Solsberry