Reputation: 37136
I built two custom Zend_Form classes: form_1 and form_2.I instanciated both of them in the same controller.
$form_1=new form_1();
$form_2=new form_2();
form_1 and form_2 have respectively submit buttons named 'submit_form_1' the first and 'submit_form_2' the second. (Ex. new Zend_Form_Element_Submit('submit_form_1')..)
So I added to my controller a snippet to check wich form was submitted :
if(($this->_request->isPost('submit_form_1')))
{
echo "you clicked for form_1!";
}
if($this->_request->isPost('submit_form_2'))
{
echo "you clicked for form_2!";
}
But it seems that clicking on either submit_form_1 or submit_form_2 both of my forms are posted! so that the above snippet output is:
you clicked for form_1!you clicked for form_2!
what am I missing?
P.s. Both of the form action are left blank so that the form post to same page(I'd prefer to not address these two forms to different actions as you might suggest =))
thanks
Luca
Upvotes: 2
Views: 2330
Reputation: 164764
Zend_Controller_Request_Http::isPost()
does not take (or use) any arguments.
Both of your conditions are evaluating to true because the request method is POST.
I think you want to use Zend_Controller_Request_Http::getPost()
instead, eg
if ($this->_request->getPost('submit_form_1', false)) {
echo "you clicked for form_1!";
}
if ($this->_request->getPost('submit_form_2', false)) {
echo "you clicked for form_2!";
}
Upvotes: 5