下午好,
我对Yii2很陌生,所以这可能很简单。
我建立了一个select2来返回相关ID:
查看:
<?= $form->field($model, 'part_id')->widget(Select2::classname(), [
'name' => 'Partselect',
'data' => $items,
'options' => ['placeholder' => 'Select a item ...', 'attribute' => 'category','id'=>'id_select'],
'pluginOptions' => [
'allowClear' => true
],
'pluginEvents' => [
"change" => 'function() {
var part_id = $(this).val();
//alert(part_id);
}',
]
]); ?>
控制器:
$modelp = PartsSearch::find()
-> where(['ID'=> ('part_id')])
-> all();
两个表是相关的
我想根据下拉菜单中选择的内容在partssearch表中显示“ cost_price_nett”。
任何帮助都是完美的!