Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2 dropdownlist onchange

Tags:

php

yii2

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?

like image 403
Alex Avatar asked Apr 22 '14 18:04

Alex


1 Answers

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() ?>
like image 154
user1852788 Avatar answered Sep 17 '22 18:09

user1852788