Hi, i am new to YII,
i have created a CRUD with GII. now i am trying to access my own created action in the controller. But i cannot access it. I am getting Error
Not Found (#404)
this is how i am trying to access it.
http://localhost/yiiBasic/web/index.php/vaults/disable-vault/10
web/index.php/vaults/disable-vault/10
Here is my controller code. i am only pasting my custom function here because rest of the actions can be accessed. Please guide me what i am missing.
<?php
namespace app\controllers;
use Yii;
use app\models\Vaults;
use app\models\VaultsSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* VaultsController implements the CRUD actions for Vaults model.
*/
class VaultsController extends Controller
{
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
return [];
}
public function actionDisableVault($id)
{
echo 'id: ' . $id; exit;
$model = $model->findModel($id);
$model->status = '0';
if ($model->load(yii::$app->request->post()) && $model->save()) {
return $this->redirect([
'index'
]);
}else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}