Closed larry-tx closed 9 years ago
First of all you should use $file->url
instead of $file->path
. The next your problem is that the value of the column must be a closure returning a string. Your solution is the following code:
[
'attribute' => 'files',
'label' => false,
'format' => 'raw',
'value' => function($data) {
$output = '';
if (isset($data->files[0]))
$output .= Html::img($data->files[0]->url);
return $output;
}
]
Thanks a million! The returning a string in the closure was my mistake in copying, but somehow, I had also overlooked the url method in your code. Again, many thanks for such an excellent extension!
Do you have any idea how to use your extension in conjunction with Katik's GridView (which for these purposes is not much different from the plain Yii2 GridView)? I've tried this approach (which I don't like because, lacking the ability to set one image a primary, I just want the first image) which simply produces a "(not set)":
I've also tried this approach which produces a "Undefined offset: 0" error:
I've also tried this approach which produces a "Setting unknown property: nemmo\attachments\components\AttachmentsTable::data" error. (The data when setting value like this is in $data, not $model):
I really enjoy your extension. The more I work with the more I find that I can get out of it! Just looking for one more way to extend it. Any help that you can provide will be most appreciated.