Is Autosubmit not working any more?

With Yii 1.1.x I used to be able to auto-submit changes from a Dropdown using this syntax:


echo CHtml::dropDownList('box', $value, $list, array('submit' => ''));

In Yii 2.0 this does not seem to work any more… I’ve tried this:


echo Html::dropDownList('box', $value, $list, ['submit' => '']);

Have I done anything wrong here or is there another way to get auto-submit back?

I had something similar some days ago.

Solved it by writing my own code to handle this.

In my example I’m reloading a Pjax-Container with ID “pjaxItemContainer”

Just an example:





echo Html::dropDownList(

	'categoryDropDown', 

	null, 

	// items for the dropdown (union of 2 arrays with +)

	['default' => 'Select Category']+Category::getArrayList(),

	['id' => 'cat_drop']	// set ID for the dropdown to get it by JS

);


$this->registerJs('

  $("document").ready(function(){ 

    $("#cat_drop").on("change", function() {       

      $.pjax.reload({

        method: "POST", 

        data: {cat_drop:$(this).val()},

        container:"#pjaxItemContainer"

      }) 

    })

  });

');




So I think you have to modify the code a littlebit…

But that should not too much work.

Regards

Thanks for that… I’ve already got a workaround which is basically this:


echo Html::dropDownList('box', $value, $list, ['onchange'=>'this.form.submit()']);

Works ok but I was wondering if and why the old method with ‘submit’=>’’ is not working any more. Was really useful!