I get an error when I use a function to get the value of an attribute and it's working normally using Gridview. What I'm doing wrong?
<?= DetailView::widget([
'model' => $model,
'attributes' => [
[
'label' => 'subject_type',
'value' => function ($data) {
return Lookup::item("SubjectType", $data->subject_type);
},
'filter' => Lookup::items('SubjectType'),
],
'id',
'subject_nature',
],
]) ?>
Fabrizio Caldarelli, on 05 January 2015 - 03:53 PM, said: Yes because 'value' attribute is a real value or attribute name, as doc says
So your code should be:
Just use call_user_func()
I have experienced this kind of problem. The error was
PHP Warning – yii\base\ErrorException htmlspecialchars() expects parameter 1 to be string, object given
what I did was transfer the function in the model like this.
and then in your view.php file..