Error 400: The CSRF token could not be verified

No Comments

Getting Error 400: The CSRF token could not be verified. when trying to delete an item using the default delete link.

$this->menu=array(
array(‘label’=>’Create Use’, ‘url’=>array(‘create’)),
array(‘label’=>’Update Use’, ‘url’=>array(‘update’, ‘id’=>$model->use_id)),
array(‘label’=>’Delete Use’, ‘url’=>’#’, ‘linkOptions’=>array(‘submit’=>array(‘delete’,’id’=>$model->use_id,’confirm’=>’Are you sure you want to delete this item?’)),
array(‘label’=>’Manage Uses’, ‘url’=>array(‘admin’)),
);

Answer:

This problem can be solved by adding ‘csrf’ => true to the linkOptions

$this->menu=array(
array(‘label’=>’Create Use’, ‘url’=>array(‘create’)),
array(‘label’=>’Update Use’, ‘url’=>array(‘update’, ‘id’=>$model->use_id)),
array(‘label’=>’Delete Use’, ‘url’=>’#’, ‘linkOptions’=>array(‘submit’=>array(‘delete’,’id’=>$model->use_id,’confirm’=>’Are you sure you want to delete this item?’),’csrf’=>true)),
array(‘label’=>’Manage Uses’, ‘url’=>array(‘admin’)),
);

Image Credits: Photo by Isis França on Unsplash.

Last Updated On March 22, 2018

Related Articles

No results found

Leave a Reply

avatar
  Subscribe  
Notify of
Menu
Copy link