【问题标题】:YII2 ad html tags to dropdownlistYII2 广告 html 标签到下拉列表
【发布时间】:2018-05-03 00:04:56
【问题描述】:

我已经创建了这样的下拉列表:

<?= $form->field($model, 'doctor_id')->widget(select2::className(),[
   'data'=>  arrayhelper::map(\app\models\doctors::find()->asArray()->all(),'doctor_id',
        function($model, $defaultValue) {
          return $model['doctor_name'].' | '. $model['doctor_id'].' | '. $model['phone1'] ;
}),
 // 'languge'=>'en',
   'options'=>['placeholder'=>'... إختر اسم الطبيب','class' => 'yuorClass'],
   'pluginOptions'=>[
   'allowClear'=>true
   ],
   ])?>

所以我需要像&lt;br&gt; 这样在$model['doctor_name'].' - '. $model['doctor_id'].' &lt;br&gt; '. $model['phone1'] ; 这样的行之间添加html标签

如图所示

【问题讨论】:

    标签: php drop-down-menu yii2 jquery-select2


    【解决方案1】:

    我没有找到我要找的东西,我改变了想法:我使用了 YII2 本身的自动完成功能:

    在控制器中:

    $patients = patient::find()->select(['concat(patient_id)  as value','  concat("(",patient_id,") ","(",mobile,") ",patient_name)  as  label','patient_id as id'])->asArray()->all();
    

    在我看来.php

    use yii\jui\AutoComplete;
    use yii\web\JsExpression; 
    
    
    echo AutoComplete::widget([ 
                'class'=> 'form-control',
                'clientOptions' => [
                'class'=> 'form-control',
                'source' => $patients,
                'minLength'=>'1', 
                'autoFill'=>true,
                'select' => new JsExpression("function( event, ui ) {
                                $('#memberssearch-family_name_id').val(ui.item.id);
                                document.location = '?r=patient1/view&id='+ui.item.id;
                            }")],
                             'options'=>[
                                        'class'=>'form-control',
                                        'placeholder'=>'بحث باسم المريض',
                ],
            ]);
    

    【讨论】:

      【解决方案2】:

      我在krajee select2here找到了我今天要找的东西

      【讨论】:

        猜你喜欢
        • 2020-07-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多