I'm trying to create A Point of sale in YII2 so i need to create a select2 for items search in sales page , i need it to search between to tables items , Bar_code i made it in tow tables because there is items have more than 1 Bar_code
I know how the select2 works and its works with me fine in on table
<?= $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
],
])?>`
but in tow its complicated or is there other way to do it ?
try this
<?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
],
])?>`