Php Yii2:Dropdownlist
我正试图在YII2中创建一个销售点,所以我需要在销售页面中创建一个select2 for items搜索,我需要它在表与表之间搜索项目,条形码我在两个表中创建了它,因为有多个项目有一个以上的条形码 我知道select2是如何工作的,我在桌上也能很好地使用它Php Yii2:Dropdownlist,php,jquery-select2,yii2-advanced-app,Php,Jquery Select2,Yii2 Advanced App,我正试图在YII2中创建一个销售点,所以我需要在销售页面中创建一个select2 for items搜索,我需要它在表与表之间搜索项目,条形码我在两个表中创建了它,因为有多个项目有一个以上的条形码 我知道select2是如何工作的,我在桌上也能很好地使用它 <?= $form->field($model, 'item_id')->widget(select2::className(),[ 'data'=> arrayhelper::map(items::find(
<?= $form->field($model, 'item_id')->widget(select2::className(),[
'data'=> arrayhelper::map(items::find()->all(),'item_id','item_name'),
'options'=>['placeholder'=>'Enter item name or scan barcode'],
'pluginOptions'=>[
'allowClear'=>true
],
])?>`
`
但总的来说,这很复杂,还是有别的办法 试试这个
<?php
$data1 = arrayhelper::map(Items::find()->all(),'item_id','item_name'),
$data2 = arrayhelper::map(Items2::find()->all(),'item_id','item_name'),
?>
<?= $form->field($model, 'item_id')->widget(select2::className(),[
'data'=> ["$data1", "$data2"],
'options'=>['placeholder'=>'Enter item name or scan barcode'],
'pluginOptions'=>[
'allowClear'=>true
],
])?>`
`