помогло только обновление пароля через админку
if(($model = ProductImg::findOne($id)) !== null){
$model->delete();
return true;
}
else{
throw new NotFoundHttpException('The requested page does not exist.');
}
<div class="row row-eq-height">
<div class="col-md-4" id="product-img-<?= $img ?>">
<div class="product-img__container">
<?= Html::img('@web/images/products/' . $img, ['alt' => '', 'class' => 'img-responsive']) ?>
<?= Html::tag('button','Delete', ['class' => 'btn btn-danger', 'onclick' => 'DeleteImg(' . $img . ')']) ?>
</div>
</div>
</div>
<?php
$this->registerJs('
function DeleteImg(id)
{
if (!confirm(\'Удалить изображение?\')) {
return false;
}
$.ajax(
{
dataType: \'html\',
url: \''. Url::to(['acts/delimage']) . '\',
type: "POST",
data: {
id: id
},
success: function (data)
{
console.log(data);
},
error : function(jqXHR) {
console.log(jqXHR.responseText);
}
});
}
', View::POS_END);
?>
class ActsController extends Controller
{
public function actionDelimage()
{
print_r(Yii::$app->request->post());
}
}
Array
(
[id] => 50
)
public function behaviors() {
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
'delete' => ['POST'],
],
],
];
}
Лучше использовать Url::toRoute()? Или как?
Подробней здесь.