click on radiobuttonlist

I have activeRadioButtonList and I need to submit form on button click (say, product controller and create action: product/create). I am new in YII and I cannot attach this submit event to radio button click. I also need to get an id of radio button pressed.

I have tried the following, it doesn’t work:




echo CHtml::activeRadioButtonList($product, 'product_id', 

              $product_list,

              array('separator'=>' ', 'labelOptions'=>array('style'=>'display:inline'),

                  'onClick'=>Yii::app()->createUrl('/product/create')

               ));



Check code below, it should works.




echo CHtml::activeRadioButtonList($product, 'product_id', 

              $product_list,

              array('separator'=>' ', 'labelOptions'=>array('style'=>'display:inline'),

                  'onclick' => 'this.form.submit()'

               ));



Ok, that worked.

Maybe you have also answered the following:

  • what if I need not to submit form, but call some link (controller + action)

  • what if I want to use ajax for call (for example, call ajax function in controller "product" and action "ajaxcall"), what format should return this function?

Thank you.