i am using Yii2, i have two tables and two models:
table 1: tenderprice:(id, itemname, quanity)(id is primary key) with model name=Tenderprice, table 2:tenderpricelist:id pk,singleprice, totalprice,tenderpriceid: (tenderpriceid is foreign key refers to Tenderprice) with model name: Tenderpricelist
now i want quantity when itemname is selected:
<?
$itemtenders=Tenderprice::find()->all();
$itemlist=ArrayHelper::map($itemtenders,'id','itemname');
echo $form->field($model, 'tenderpriceid')->dropDownList($itemlist,['prompt'=>'Select tender'])->hint('Please choose item one by one')->label('Add Items');
?>
// inserting data into tenderpricelist based on the selection of table tenderprice
<?= $form->field($model, 'singleprice')->textInput(['maxlength' => true])->hint('Please enter your price') ?>
<?= $form->field($model, 'totalprice')->textInput(['maxlength' => true]) ?>
now i want to insert data into tenderpricelist table based on the item name selected from dropdownlist…the dropdownlist fills correctly but i cannot access the value of “quantity” column when itemname is selected.
i just want when i select item name from the dropdownlist, its corresponding quanity will be shown on textbox or label and the totalprice column in my table tenderpricelist will be : totalprice
totalprice=quantity *singleprice
note: singleprice is in table tenderpricelist, while quantity is in parent table tenderprice, please help me?