I am trying to create a test form in the view that I have. So far I have only very simple fields to check if everything is working correctly (this is not the case)
$this->Form->create('user', array('url'=>array('controller'=>'users', 'type' => 'post', 'action'=>'add'))); echo $this->Form->input('username'); echo $this->Form->end(__('Submit', true));
Now it prints the submit button, and I assume that when she clicks it, it will call the add function in my UsersController.php file.
However, I have something similar in the controller file
class UsersController extends AppController { ....... public function add() { if ($this->request->is('post')) { debug(TEST); die; $this->User->create(); if ($this->User->save($this->request->data)) { $this->Session->setFlash(__('The user has been saved')); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The user could not be saved. Please, try again.')); }}} ........ }
Pay attention to debug and die there, when I submit the debug version, it does not print TEST, and nothing happens on the page, so I assume that my form does not submit properly, I honestly have no idea why, I base my approach on solutions found here How to send a form for one model to someone elseโs controller?
source share