Exchange onchange event for submit button for ActiveForm

Hi all. I’m currently looking for a way to successfully add an event handler for a drop down menu with yii2. The closest solution to this so far is http://kalkanotel.com/yii2-how-to-add-onchange-event-in-activeform-i59116.htm.


In the ActiveForm I have the following:


<?php $form = ActiveForm::begin([

	'options' => ['enctype' =>

	'multipart/form-data'],

	'layout' => 'horizontal']); ?>

 

   <?= $form->field($model, 'brand_id', [

    'horizontalCssClasses' => [

    'wrapper'  => 'col-sm-3',

    'label' => 'hidden', 

]])->dropDownList($dataBrandName, array ('onchange'=>'getData()',

  'class' =>'form-control',  

  'prompt'=>' ----- Select by Brand -----', 

  'selected'=>'selected',

  

    

  )  ) ?>     



This produces a drop down without use of javascript; however when a brand is selected there is no result. If anyone can point me in the direction of a working example or explain what I need to do to submit this via onchange or onclick I would greatly appreciate it.

Thanks

its working in my case.

form is submitted on dropdown change/


  <?= $form->field($model, 'brand_id', [

    'horizontalCssClasses' => [

    'wrapper'  => 'col-sm-3',

    'label' => 'hidden', 

]])->dropDownList($dataBrandName, ['onchange'=>'this.form.submit()'],

  'class' =>'form-control',  

  'prompt'=>' ----- Select by Brand -----', 

  'selected'=>'selected',

  

    

  )  ) ?>    

Thank you very much rups g. It is working in my case as well. I switched a closing bracket to eliminate a syntax challenge, but we are good to go.


<?= $form->field($model, 'brand_id', [

    'horizontalCssClasses' => [

    'wrapper'  => 'col-sm-3',

    'label' => 'hidden', 

]])->dropDownList($dataBrandName, ['onchange'=>'this.form.submit()',  'class' =>'form-control',  

  'prompt'=>' ----- Select by Brand -----', 

  'selected'=>'selected',

  

    

  ]  ) ?>