public function actionDelete($id, $type = null) { // Find Model $model = TemplateService::findById($id); // Delete/Render if exist if (isset($model)) { if ($model->load(Yii::$app->request->post(), 'Template') && $model->validate()) { if (TemplateService::delete($model)) { return $this->redirect($this->returnUrl); } } return $this->render('@cmsgears/module-core/admin/views/template/delete', ['model' => $model]); } // Model not found throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND)); }