Dynamic Forms

Hi! I need some help with a dynamic form. I am using bootstrap.widgets.TbActiveForm and would like some form fields to appear only if a checkbox is selected. So if posix is selected, more fields should appear below.

This can be done with a regular html form using javascript, but are there any way to do this "the yii way"?

This is the code, and I would like more options to appear below the checkbox if posix is selected.

$form = $this->beginWidget(‘bootstrap.widgets.TbActiveForm’, array(

'id'=>'addUser',


'htmlOptions'=>array('class'=>'well'),


'type'=>'horizontal',


'enableClientValidation'=>true,

‘clientOptions’ => array(

‘validateOnSubmit’=>true,

‘validateOnChange’=>true,

‘validateOnType’=>true,),

)); ?>

<?php echo $form->errorSummary($user); ?>

<?php echo $form->textFieldRow($user, ‘uid’, array(‘class’=>‘span3’)); ?>

<?php echo $form->textFieldRow($user, ‘givenname’, array(‘class’=>‘span3’)); ?>

<?php echo $form->textFieldRow($user, ‘sn’, array(‘class’=>‘span3’)); ?>

<?php echo $form->textFieldRow($user, ‘cn’, array(‘class’=>‘span3’)); ?>

<?php echo $form->textFieldRow($user, ‘mail’, array(‘class’=>‘span3’)); ?>

<?php echo $form->textFieldRow($user, ‘mobile’, array(‘class’=>‘span3’)); ?>

<?php echo $form->passwordFieldRow($user, ‘userpassword’, array(‘class’=>‘span3’)); ?>

<?php echo $form->checkBoxListRow($user, ‘objectclass’, CHtml::listData(

    array(


        array(


            'type' =&gt; 'inetOrgPerson',


            'text' =&gt; 'inetOrgPerson - Standard user',


        ),


        array(


            'type' =&gt; 'posix',


            'text' =&gt; 'Posix user - User with UNIX account',


        ),


        ),


        'type','text'),


    array('hint'=&gt;'&lt;strong&gt;Note:&lt;/strong&gt; Select one or more accountypes.')); ?&gt;

Robert