5.5.2.4 The Parameters Attribute ($params)
Controller parameters are available at $this->params in your CakePHP controller. This variable is used to provide access to information about the current request. The most common usage of $this->params is to get access to information that has been handed to the controller via POST or GET operations.
5.5.2.4.1 form
$this->params['form']
$this->params['form']
Any POST data from any form is stored here, including information also found in $_FILES.
5.5.2.4.2 bare
$this->params['bare']
$this->params['bare']
Stores 1 if the current layout is empty, 0 if not.
5.5.2.4.3 isAjax
$this->params['ajax']
$this->params['ajax']
Stores 1 if the current layout is set to ‘ajax’, 0 if not. This variable is only set if the RequestHandler Component is being used in the controller.
5.5.2.4.4 controller
$this->params['controller']
$this->params['controller']
Stores the name of the current controller handling the request. For example, if the URL /posts/view/1 was requested, $this->params['controller'] would equal "posts".
5.5.2.4.5 action
$this->params['action']
$this->params['action']
Stores the name of the current action handling the request. For example, if the URL /posts/view/1 was requested, $this->params['action'] would equal "view".
5.5.2.4.6 pass
$this->params['pass']
$this->params['pass']
Stores the GET query string passed with the current request. For example, if the URL /posts/view/?var1=3&var2=4 was requested, $this->params['pass'] would equal "?var1=3&var2=4".
5.5.2.4.7 url
$this->params['url']
$this->params['url']
Stores the current URL requested, along with key-value pairs of get variables. For example, if the URL /posts/view/?var1=3&var2=4 was called, $this->params['url'] would contain:
[url] => Array
(
[url] => posts/view
[var1] => 3
[var2] => 4
)
[url] => Array([url] => posts/view[var1] => 3[var2] => 4)
5.5.2.4.8 data
$this->data
$this->data
Used to handle POST data sent from the FormHelper forms to the controller.
<?php
// The FormHelper is used to create a form element:
$form->text('User.first_name');
// When rendered, it looks something like:
<input name="data[User][first_name]" value="" type="text" />
// When the form is submitted to the controller via POST,
// the data shows up in $this->data.
//The submitted first name can be found here:
$this->data['User']['first_name'];
?>
<?php// The FormHelper is used to create a form element:$form->text('User.first_name');// When rendered, it looks something like:<input name="data[User][first_name]" value="" type="text" />// When the form is submitted to the controller via POST,// the data shows up in $this->data.//The submitted first name can be found here:$this->data['User']['first_name'];?>
