Answer the question
In order to leave comments, you need to log in
How to display GridView::widget without reloading the page depending on the selections in the ActiveForm field?
Good afternoon.
Faced the following problem:
There is a form for creating a batch of products ActiveForm. When choosing a product brand via AJAX, I generate a batch number:
view code
<?= $form->field($model, 'id_marka')
->dropDownList(\app\models\Marka::find()
->select(['title','id'])
->indexBy('id')
->column(),
[
'prompt' => '',
'onchange' => '$.post(
"'.Url::toRoute('part/num-part').'",
{id : $(this).val()},
function(data){
$(".part-number").val(data)
}
)'
]
)
?>
public function actionNumPart()
{
if(Yii::$app->request->isAjax)
{
$id = (int)Yii::$app->request->post('id');
$result = Part::getNumber($id);
}
return $result;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question