Greets.
{{Solved}}
In order to get POST data you MUST use $this->formHidden in order to hold all the data. Even though variables are inside the they don’t get passed if they aren’t in some sort of form item.
I am unable to access post data in ZEND.
Path of User –
START
INDEX PAGE
->Submit Page
->Pay Page
I created a controller, extended the Zend Controller, and added an action called payAction. The user can go from the Index Page to the Submit Page. After I have all their data inside variables, I used a form and a submit button to go to the “pay page”. However, I cannot get any of the POST data.
public function payAction()
{
$data = $this->getRequest();
}
I have tried putting getRequest, getParam, getRawBody inside that controller function.
In the page itself I have tried.
echo 'Hello';
echo $request;
echo $data;
echo $_POST['payZip'];
echo $_POST['data'];
echo $_POST[$data];
echo $request;
echo $this->values['payZip'];
echo $payZip;
echo $this->values['shippingDone'];
echo $stuff;
Is there ANYTHING I can place in my controller or in my view in order to get my post data? I used a form method=”post” and a button and it DOES allow me to get to the page. I can see Hello. But NONE of the post data is available.
Any assistance would be appreciated.
Thank you.
— Update
$data = $this->getRequest();
$param = $this->_request->getParam('payZip');
if($this->getRequest()->isPost())
{
print_r($this->_getAllParams());
echo $param;
}
Doing that gives me –
HelloArray ( [controller] => wheel [action] => pay [module] => default [shipping] => UPS Ground [payPal] => Secure Payment System )
But I still can’t print payZip… I did echo and nothing comes out.
To get parameters from Zend Framework you need to do this in the Action Controller:
You can also get individual params like this
What it appears your doing wrong is you’re only getting the “request object”. You need to then call that objects method to get the request data.
Here’s some simple code I often use when testing parameters:
This will show all your parameters. What you will notice is that you will also get the names of the Module, Controller and Action with your params.
EDIT
Ps. If you’re trying to use the parameter in the view script you need to do this:
In your Action Controller, you save your data to the “view” object by doing this:
But when you’re in a view script, you are IN the view script, so
$thisrepresents$this->viewfrom the action controller.So, you access the variable like this:
Wrapping everything into a bigger code chunk for understanding:
Your Controller
Your View Script
I hope that helps!