Receive and publish in cakephp

In Codeigniter, I do it

$p=$this->input->post(); 

so that all objects are submitted, but I don’t know if there is something like this in cakephp to get all published variables from the form? I am writing a function to get the published password and save it to the database instead of the old password registered there.

I use native php to get the "posted" variables from the form (I am not familiar with the use of cakephp form), so instead of using $ _POST ['sssss], what should I do now?

Thanks for any help.

+8
source share
8 answers
 $value = $this->request->data('key'); 

Please consult for more information, read the manual. It is much easier and better for yourself to understand yourself.

http://book.cakephp.org/2.0/en/controllers/request-response.html#accessing-post-data

+9
source share
  for the GET method $this->request->query['category-name']; and POST method $this->request->data 

http://book.cakephp.org/2.0/en/controllers/request-response.html#accessing-querystring-parameters

+6
source share

Post data must be in the data to be displayed in the $ this-> request-> data.

Example:

 // input field <input type="text" name="data[foo]" value="bar" /> // in your controller debug($this->request->data); 
+2
source share

You can check if you have posted the form with

 if (!empty($this->data)) { print_r($this->data); } 
+2
source share

To check if a form has been posted, use:

 if ($this->request->is('post')) { pr($this->request->data); } 
+2
source share

If you want to get a specific table field, you can navigate like this:

 if($this->data["Objetorastreavel"]["id"]){ } 

It only checks the Objetorestraeval identifier if you want to select only one field and not fit the entire page.

+2
source share

You can access the data in the message form using:

For CakePHP 2.x

 if ($this->request->is('post')) { pr($this->request->data); } 

For CakePHP 3.4.x

 if ($this->request->is('post')) { pr($this->request->getData()); } 

Documentation for CakePHP 3

0
source share

You can use the following data to receive messages / receive data in CakePHP

For post data: $this->request->data;

To get data: $this->request->query;

0
source share

All Articles