Search code examples
phpyiiradiobuttonlist

Yii: Issue in RadioButtonList


Problem in radioButtonList. I am having two radio buttons as shown below. I am performing AJAX action on first radio button.

But when I try click the second radio button, the first one is not getting unchecked and I am not able to check the second one.

<?php echo CHtml::radioButtonList( 'ck_Skill','',
    array(4 => 'Professional Skill', 5 => 'Suggestion'), 
    array('separator' => ' ',
    'onChange'=>CHtml::ajax(array('type'=>'POST', 'dataType'=>'json',"url" =>array("search/search"),
    "success"=>"function(response){
         $('#textfield-wrapper').html(response.data);
     }",
))));?>

What I am missing here ?


Solution

  • I think this article can help:

    http://www.yiiframework.com/wiki/110/styling-radio-buttons/

    Or even this one: http://code.dimilow.com/yii-radio-button-list-example-or-how-to-remove-the-line-break-separator/

    Things that I notice in your code (Yii class reference):

    • Where is the model?
    • Where the select name?

    Anyway, below an example of this, try take out your javascript code, to make easier figure out the problem:

    <?php echo CHtml::radioButtonList($model, 'ck_Skill',
        array(4 => 'Professional Skill', 5 => 'Suggestion'), 
        array('separator' => ' ',
        'onChange'=>CHtml::ajax(array('type'=>'POST', 'dataType'=>'json',"url" =>array("search/search"),
        "success"=>"function(response){
             $('#textfield-wrapper').html(response.data);
         }",
    ))));?>