加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

Cakephp表单没有提交

发布时间:2020-12-13 17:16:23 所属栏目:PHP教程 来源:网络整理
导读:我试图在我看到的视图中制作一个测试表单.到目前为止,我只有非常简单的字段来测试一切是否正常(不是) $this-Form-create('user',array('url'=array('controller'='users','type' = 'post','action'='add')));echo $this-Form-input('username');echo $this-F
我试图在我看到的视图中制作一个测试表单.到目前为止,我只有非常简单的字段来测试一切是否正常(不是)

$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.'));
 }}}

  ........

}

注意那里的调试并死在那里,当我提交调试时不打印TEST并且页面上没有任何反应,所以我认为我的表单没有正确提交.老实说,我不知道为什么,我一直在这里找到解决方案
How to submit form for one model in another’s controller?

解决方法

找到解决方案,因为在创建表单之前缺少回声而被卡住了几个小时,我以为那些只是打印东西.我觉得非常可怕

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读