2amigos / yii2-grid-view-library

Highly enhanced GridView widget and grid components for Yii2
https://2amigos.us
Other
57 stars 16 forks source link

Is it possible to set the type of the column dynamically? #18

Closed gb5256 closed 7 years ago

gb5256 commented 9 years ago

Hi, I have something like this:

  'class' => \dosamigos\grid\EditableColumn::className(),
                    'attribute' => 'value',
                    'url' => ['editable'],
                    'type' => function($model) { return $model->type; },

I do store in my model also a 'Type' attribute, as some users should see a drop down, other not. But the above does throw an error: htmlspecialchars() expects parameter 1 to be string, object given. I tried already (just to see if it is working) to set the type without the model, like this:

     'type' => function($model) { return 'text'; },

Gives me the same error. I can do that on values, etc but not on the type. hmmm. is there a workaroud?

tonydspaniard commented 7 years ago

Unfortunately not at this time. That is an issue with the render attributes of Yii itself.