问题描述
当我从购物车中删除商品并单击删除按钮时。它实际上删除了该项目,但它给了我这个错误。
我的代码如下:
<td>
<?= $this->Form->create(null,[ 'url'=>['controller' => 'Carts','action' => 'delete',$cart->id]]); ?>
<?= $this->Form->hidden('cart->id',['value'=>$cart->id]); ?>
<?= $this->Form->submit('add to cart'); ?>
</td>
小车控制器如下:
public function delete($id = null)
{
$this->request->allowMethod(['post','delete']);
$cart = $this->Carts->get($id);
if ($this->Carts->delete($cart)) {
$this->Flash->success(__('The cart has been deleted.'));
} else {
$this->Flash->error(__('The cart Could not be deleted. Please,try again.'));
}
return $this->redirect(['action' => 'index']);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)