在我的 yii2 项目中,我想为我的图像获取复选框,以便按图像搜索。每当用户选中复选框并提交按钮时,它应该只显示那些选中的图像的内容。
我的复选框列表
<?php $img = ArrayHelper::map(app\models\GhsPictogram::find()->all(), 'pictogram_id', 'pictogram_filepath') ?>
<?= $form->field($model, 'ghsPictogram',['template'=>'<div class="ghs-pict"> {label}{input} </div>'])->checkboxList($model->imageList($img)) ?>
我的模型中的 imageList 方法
public function imageList($filenames) {
$imageList = [];
foreach ($filenames as $key => $value) {
$imageList[$key] = Html::img(
Yii::$app->request->baseUrl . 'web' . $value,
'', array("style"=>"width: 50px")
);
}//foreach $filenames
return $imageList;
}
但在我的表单中,它不显示图像。它改为显示图像 src。
帮助我找到如何在搜索表单字段中显示图像。谢谢