Changing partial view through radio buttons

I have reached a roadblock and hope one of the YII experts can help.

2 JUI Radio Buttons (Button Set) on a view are supposed to switch out a partial view. I was hoping I could just call a controller action when one of the radio buttons is clicked to achieve this. The action is supposed to re-render the view with a different partial view.

This is all happening on the logon form (see attachment). I want to allow people to logon or to sign up. logon needs less fields than sign up, also a different model (LogonForm versus User).

Is this possible?

Here is the code:


$this->beginWidget(‘zii.widgets.jui.CJuiButton’, array(



‘themeUrl’=> Yii::app()->theme->baseUrl . ‘/jquery-ui-1.8.22.custom/css’ ,



$this->widget(‘zii.widgets.jui.CJuiButton’, array(



‘caption’=>‘sign up’,


‘value’=>array(‘checked’=>‘checked’) ,


‘onclick’=>‘js:function(){$.ajax({type: “POST”,url: “http://localhost/yii/TeamDynamics/index.php?r=site/switch”}); }’,


$this->widget(‘zii.widgets.jui.CJuiButton’, array(






‘onclick’=>‘js:function(){$.ajax({type: “POST”,url: “http://localhost/yii/TeamDynamics/index.php?r=site/switch”}); }’,




Thank you,


It is possible (although I never used the JUIButtons).

1.) I would create a separate action for signup and login as opposed to site/switch

2.) Check if the request to an action is done via ajax in your actions and only partially render the view when this is the case




    //use $this->renderPartial('signup',$data,false,true); when your view contains js that has to be rendered too (fourth parameter => true)

    Yii::app()->end(); //As this is an ajax request you can end the app here




3.) You have to define a success callback in your js code to handle the response (the rendered partial). I wouldn’t use a POST as you aren’t posting anything yet. You only want to render the appropriate view I guess so a GET would be better. The rendered partial will then be placed into an element with id #container.



        type: "GET",

        url: "'.$this->createUrl('site/signup').'"

        success : function(data) {





Hope it helps



Thank you so much. This helped me get past my roadblock.

Beste Gruesse,