0
在我的yii2項目中,我想獲取我的圖像複選框以便按圖像搜索。每當用戶選中複選框並提交按鈕時,它應該只顯示那些檢查圖像的內容。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)) ?>
我的圖像列表的方法在我的模型
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。
幫我找到我怎麼能在搜索表單域顯示圖像。謝謝