Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Yii 1 中,我可以通过这种方法为 dropDownList 设置 onchange 事件:
CHtml::dropDownList('id', $select, $list, array('onchange'=>'this.form.submit()'))
它非常好。但是在 Yii 2 中它不起作用,我该如何解决这个问题?
此代码正确提交更改:
<?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() ?>