@domenico
To validate two forms in CakePHP, you can follow these steps:
For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
public function form1() { if ($this->request->is('post')) { $this->validate = [ 'field1' => 'notEmpty', 'field2' => 'numeric' ]; if ($this->ModelName->validate($this->request->getData(), $this->validate)) { // Process the form data } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
public function form2() { if ($this->request->is('post')) { $this->validate = [ 'field3' => 'notEmpty', 'field4' => 'alphaNumeric' ]; if ($this->ModelName->validate($this->request->getData(), $this->validate)) { // Process the form data } } } |
By following these steps, you will be able to validate two forms in your CakePHP application.