我想使用postLink删除记录但在一个地方它正在工作,而在另一个视图中它会出现以下错误:
POST数据中的意外字段'example1_length' 它不会进入类别控制器。
echo $this->Form->postLink('<button class="btn btn-danger fa fa-trash"></button>',
array('action'=> 'delete', $cat->category_id),array('class'=> 'tip','escape' => false,'confirm' => 'Are you sure ?')); ?>
CategoriesController.php
public function delete($id)
{
if($this->request->is('post') || $this->request->is('put'))
{
$categories = $this->Categories->get($id);
if ($this->Categories->delete($categories)) {
$this->Flash->success(__('The Category with id: {0} has been deleted.', h($id)));
return $this->redirect(['action' => 'view']);
}
}
else
{
$this->autoRender = false;
echo "you are not authorized to view this page";
}
}
当显示错误页面时,它显示产品控制器URL,但我正在使用类别控制器。请帮助解决这个问题。