4
我想在视图中制作测试表单。到目前为止,我只有很简单的领域,以测试是否一切工作的权利(这不是)Cakephp表单不提交
$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文件。
不过,我有这样的事情在控制器文件
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.'));
}}}
........
}
注意调试那里死在那里,当我提交调试不打印测试并没有任何反应在页面上使我假设我的表单没有正确提交。老实说,我不知道为什么,我一直立足我在这里找到的解决办法 How to submit form for one model in another's controller?
适合所有人:)。你能否将自己的答案标记为可以接受,以便正确标记它? – Nunser 2013-05-02 13:09:47