2017-04-25 52 views
0

我想在YII2中創建一個銷售點,所以我需要在銷售頁面中創建一個select2項目搜索,我需要它在表格項目之間搜索,Bar_code因爲我在兩個表格中進行了搜索有項目比1 Bar_codeYii2:Dropdownlist

我知道選擇2作品及其作品與我怎麼罰款上表

<?= $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 
    ], 
])?>` 

但在拖它的複雜,還是有其他辦法做到這一點嗎?

回答

0

試試這個

<?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 
    ], 
])?>` 
相關問題