我创建了这样的下拉列表:
<option name="Development" value="<?php echo $row['Development']; ?>
所以我需要在<?= $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
],
])?>
这样的行之间添加html标记,如<br>
如图所示
答案 0 :(得分:0)
我确实找不到我想要的东西,我改变了主意:我使用了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'=>'بحث باسم المريض',
],
]);
答案 1 :(得分:0)
我在krajee select2
here