2017-09-07 161 views
1

由於某些要求,我需要在單選按鈕列表中顯示帶有標籤的圖像。Radiobutton中的標籤顯示圖像 - Yii2

我搜索了How to insert an Image List into a radioButtonList?。並納入變化。

查看

<?php 
$model->pay_type = 1; 
echo $form->field($model, 'pay_type')->radioList($model->paymentOptionRadioButtonList())->label(false); 
?> 

型號

<?php 
public function paymentOptionRadioButtonList(){ 
    $payment_options = $params->payment_type; 

    foreach($payment_options as $key => $val){ 
    $payment_options[$key] = $val.yii\helpers\Html::img('www.dummy.com/'.'company-default-logo.jpg'); 
    } 
    return $payment_options; 
} 

?> 

輸出:

enter image description here

而不是顯示圖像,它顯示<img src="www.dummy.com/company-default-logo.jpg" alt="">

是否有任何參數我需要通過單選按鈕列表中顯示圖像?

回答