我是 yii2 的新手,我正在尝试创建一个 ActiveForm,我可以在其中选择多个项目及其数量,并能够计算总金额,因为每个项目都有价格。
<?php
$form = ActiveForm::begin(['action' =>['sales/create'], 'id' => 'new-sales', 'method'=>'post',]); ?>
<div class="container-fluid row">
<div class="col-md-8">
<?=
$form->field($model, 'product_name')
->dropDownList(
arrayHelper::map(Product::find()->all(),'product_name','product_name'),
['prompt' => 'Select product', 'class' => 'form-control text-center', 'id'=>'pname']
) ?>
</div>
<div class="col-md-4">
<?= $form->field($model, 'quantity')->textInput([
'type' => 'number', 'min' => 1, 'class' => 'form-control', 'id' => 'qnt'
]) ?>
</div>
<div class="col-md-6">
<?= $form->field($model, 'amount')->textInput(['class'=> 'form-control']); ?>
</div>
</div>