不能删除cakephp3中的第一行

时间:2017-01-31 01:00:13

标签: cakephp cakephp-3.0

以下删除工作正常,除非我尝试使用以下函数删除表的第一行。会发生什么是浏览器没有重定向到删除功能(没有错误)。这似乎是一个怪癖,因为删除功能适用于其他每一行。问题只是表的第一行,我可以从mysql手动删除第一行。我不知道为什么会这样做。

//view  

<?= $this->Form->postLink('<i class="fa fa-trash"></i> ',  ['action' => 'delete', $item->id],
   [   'escape' => false, 'confirm' => __('Are you sure, you want to delete {0}?', $item->id)  ]) ?>

//controller
public function delete($id = null)
    {

       $this->request->allowMethod(['post', 'delete']);
        $schedulestudent = $this->Schedulestudents->get($id);
        if ($this->Schedulestudents->delete($schedulestudent)) {
            $this->Flash->success(__('The schedulestudent has been deleted.'));
        } else {
            $this->Flash->error(__('The schedulestudent could not be deleted. Please, try again.'));
        }
        return $this->redirect(['action' => 'studentschedule']);
    }

1 个答案:

答案 0 :(得分:0)

我在下面的命令之前有了postlink。所以我应该在关于cake3表格手册的更多相关内容之后先关闭表格。我不能在表单块中使用postlinks

echo $ this-&gt; Form-&gt; end();

相关问题