5.5.2.4 Das Parameter-Attribut ($params)

Controller-Parameter sind über $this->params in Deinem CakePHP Controller verfügbar. Diese Variable dient der Bereitstellung von Informationen über den aktuellen Request. Am häufigsten wird $this->params genutzt, um auf Daten zuzugreifen, die per POST- oder GET-Operationen an den Controller übergeben wurden.

5.5.2.4.1 form

$this->params['form']
  1. $this->params['form']

Die POST Daten jeder Form werden hierin gespeichert, inklusive der Informationen aus $_FILES.

5.5.2.4.2 bare

$this->params['bare']
  1. $this->params['bare']

Stores 1 if the current layout is empty, 0 if not.

5.5.2.4.3 isAjax

$this->params['ajax']
  1. $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']
  1. $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']
  1. $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']
  1. $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']
  1. $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
)
  1. [url] => Array
  2. (
  3. [url] => posts/view
  4. [var1] => 3
  5. [var2] => 4
  6. )

5.5.2.4.8 data

$this->data
  1. $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'];

?>
  1. <?php
  2. // The FormHelper is used to create a form element:
  3. $form->text('User.first_name');
  4. // When rendered, it looks something like:
  5. <input name="data[User][first_name]" value="" type="text" />
  6. // When the form is submitted to the controller via POST,
  7. // the data shows up in $this->data.
  8. //The submitted first name can be found here:
  9. $this->data['User']['first_name'];
  10. ?>