Hi there.
I have a standard backend where I can delete models. I want to guard this action with the usual confirm message and to filter it with the DELETE verb in my controllers.
In my tags/index.php view, the delete link appears as a button like this :
<?= Html::a('<span class="glyphicon glyphicon-trash">', $url, [
'class' => 'btn btn-danger btn-xs',
'data' => ['confirm' => HLib::t('messages', 'Are you sure you want to delete this item?'), 'method' => 'delete',],
]) ?>
and the generated HTML is :
<a class="btn btn-danger btn-xs" data-method="delete" data-confirm="Etes-vous sûr de vouloir supprimer cet objet ?" href="http://127.0.0.1:8061/tags/delete?id=38">
<span class="glyphicon glyphicon-trash"></span>
</a>
The controller filters incoming requests as usual :
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
'delete' => ['delete'],
],
],
];
}
This links appears in a custom grid view (not the yii\grid\GridView).
It works as expected : after the confirmation dialog, the request is processed and the object is deleted.
Now, in my form, I have the same code (same PHP code except for the button glyph, and same HTML generated code)
But when I click the ‘delete’ link in the form, Yii throws an error :
BTW, in access logs from Apache the accessed url is incorrect :
(valid URL : http://127.0.0.1:8061/tags/delete?id=38)
I’m lost.
Any idea of what’s going on ?