Reputation: 443
can anyone please tell me why im getting this error ? (the parameter is set i can get it value by echo)
Too few arguments to function app\controllers\admin\SiteDeveloperController::actionView(), 0 passed and exactly 1 expected
+info i passed user identity to view file by mycontroller indexaction so i can access the user id in view with $user->id ;
public function actionIndex()
{
$this->layout = "site-developer";
if (Yii::$app->user->can('superuser')) {
if (!Yii::$app->user->isGuest) {
$user = Yii::$app->user->identity;
return $this->render("index", [
'user' => $user
]);
} else {
echo "you cant access this";
}
} else {
throw new ForbiddenHttpException("you cant access this");
}
}
no im trying to pass the current $user->id to mycontroller actionView ... but it say (ArgumentCountError 0 passed and exactly 1 expected)
public function actionView($id)
{
$mode = $this->findModel($id);
print_r($mode);
//return $this->render("view");
}
and this is the button that pass the id to controllers action
<?= Html::a('<span class="glyphicon glyphicon-user"></span><br>پروفایل',['view','id' => $user->id],['class' => 'btn btn-primary btn-lg'])?>
Upvotes: 1
Views: 780
Reputation: 443
after few hours + deep search i find out my controller name space is yii**base**\Controller; it should be use yii**web**\Controller; i hope it help some yii2 user for decrease thier debug time
Upvotes: 8