munsifali
munsifali

Reputation: 1732

CakePHP request params

difference between $this->request->params and $this->request->data

I was reading the CakePHP manual on $this->request->params and was wondering what the appropriate usage is for each? Can someone show an example of why it would be important to use one over the other?

Upvotes: 0

Views: 3563

Answers (2)

Ali
Ali

Reputation: 366

Request is the default request object used in CakePHP. It centralizes a number of features for interrogating and interacting with request data.Request is assigned to $this->request, and is available in Controllers, Views and Helpers. You can also access it in Components by using the controller reference. Some of the duties CakeRequest performs include:

Process the GET, POST, and FILES arrays into the data structures

Request exposes several interfaces for accessing request parameters. The first uses object properties, the second uses array indexes, and the third uses $this->request->params eg.

$this->request->controller;
$this->request['controller'];
$this->request->params['controller'];

for further information see documentation

Upvotes: 1

Ram Sharma
Ram Sharma

Reputation: 8809

if you use the FormHelper it will show up in $this->request->data and if you don't use the FormHelper it will show up in $this->request->params or $this->request->params['form'].

Upvotes: 1

Related Questions