In Yii 1 i could set onchange event for dropDownList by this method:
CHtml::dropDownList('id', $select, $list, array('onchange'=>'this.form.submit()'))
And it was pretty good. But in Yii 2 it doesn't work, how do i solve this issue?
this code submits on change properly:
<?php use yii\helpers\Html; ?>
<?= Html::beginForm() ?>
<?= Html::dropDownList(
'test', //name
'b', //select
['a'=>'A', 'b'=>'B'], //items
['onchange'=>'this.form.submit()'] //options
)?>
<?= Html::endForm() ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With