Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check if request is post in Zend Framework

I remember using something like

$this->getRequest()->isPost()

but it seems like there isn't such a function. How can I check if the request is post so I can validate the form etc

like image 910
Jiew Meng Avatar asked Dec 19 '10 03:12

Jiew Meng


3 Answers

$this->getRequest() in the context of a controller is annoted to return an object of class Zend_Controller_Request_Abstract. isPost() is a method of Zend_Controller_Request_Http which is derived from Zend_Controller_Request_Abstract.
So your IDE cannot offer this method, but it is there.

like image 187
Maxence Avatar answered Nov 15 '22 09:11

Maxence


if ($this->getRequest()->isPost()) 
{
    echo "this is post request";
} 
else 
{ 
    echo "this is not the post request";
}
like image 16
Kdecom Avatar answered Nov 15 '22 07:11

Kdecom


   if($this->getRequest()->getMethod() == 'POST') {
       echo "You've got post!";
   }

isPost() should be there too, though, I don't know why you don't find it.

like image 10
StasM Avatar answered Nov 15 '22 09:11

StasM