Cakephp表单未提交


Cakephp form not submitting

我正试图在一个视图中创建一个测试表单。到目前为止,我只有非常简单的字段来测试是否一切正常(它不是)

$this->Form->create('user', array('url'=>array('controller'=>'users', 'type' => 'post', 'action'=>'add')));
echo $this->Form->input('username');
echo $this->Form->end(__('Submit', true));

现在打印提交按钮,我假设当它点击它时,它会调用UsersController.php文件中的"add"函数。

但是我在控制器文件

中有这样的内容
 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.'));
 }}}
  ........
}

注意debug那里和die那里,当我提交调试不打印TEST,页面上没有发生任何事情,所以我假设我的表单没有正确提交。老实说,我也不知道为什么,我一直把我的方法建立在这里找到的解决方案上如何在另一个's控制器中为一个模型提交表单?

找到了解决方案,因为在创建表单之前缺少echo而被卡住了几个小时,我认为那些只应该打印东西。我感觉糟透了