V
V
Vyacheslav Soldatov2022-02-15 22:39:20
Yii
Vyacheslav Soldatov, 2022-02-15 22:39:20

How to fix Argument 2 passed to yii\base\View::{closure}() must be an instance of users, instance of app\models\Users given?

in C:\OpenServer\domains\medicalcentr\modules\admin\views\users\index.php

'id',
'name',
'patronymic',
'surname',
'login',
//'password',
//' position',
[
'class' => ActionColumn::className(),
'urlCreator' => function ($action, users $model, $key, $index, $column) {
return Url::toRoute([$action, 'id' => $model->id]);
}
],
],
]); ?>

I can't figure out where the error is. I am newbie,

<?php
NavBar::begin([
'brandLabel' => Yii::$app->name,
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar navbar-expand-md navbar-dark bg-dark fixed-top',
],
]);
echo Nav::widget([
'options' => ['class' => 'navbar-nav'],
'items' => [
['label' => 'Home', 'url' => ['/site /index']],
['label' => 'Applications', 'url' => ['/admin/application/index']],
['label' => 'Users', '
url' => ['/admin/users/index']], Yii::$app->user->isGuest ? (
['label' => 'Login', 'url' => ['/site/login']]
) : (
''
. Html::beginForm(['/site/logout'], 'post', ['class' => 'form-inline'])
. Html::submitButton(
'Logout (' . Yii: :$app->user->identity->username .')',
['class' => 'btn btn-link logout']
)
.Html::endForm()
.''
)
],
]);
NavBar::end();
?>

everything went wrong, I hope for your help!!!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vyacheslav Soldatov, 2022-02-15
@6xisp1

I could not find any information on various ruforums, I hope for your help!

S
Sergey, 2022-02-15
@werwolflg

Because you either need to replace users with Users. Or remove it altogether. The parameter type is incorrect.
Here:

'urlCreator' => function ($action, users $model, $key, $index, $column) {

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question