redio button panel


i have 2 question.

  1. i am new in YII and working in a form, on that yes and no option in redio button if redio.value =yes then text box enable and user enter comments,

<div class="row">

	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'prior_PCI'); ?&gt;

	&lt;?php echo &#036;form-&gt;radioButton(&#036;model,'prior_PCI',array('value'=&gt;1,'uncheckValue'=&gt;null)); ?&gt;

	&lt;?php echo &#036;form-&gt;radioButton(&#036;model,'prior_PCI',array('value'=&gt;1,'uncheckValue'=&gt;null)); ?&gt;

	&lt;?php echo &#036;form-&gt;error(&#036;model,'p[b][/b]rior_PCI'); ?&gt;

      i need below script in _form.php (view)

         //   if prior_pci.value=1 then      

    //	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'comments'); ?&gt;

//	&lt;?php echo &#036;form-&gt;textField(&#036;model, 'comments', array('maxlength' =&gt; 45)); ?&gt;

      //     endif

  1. how a js script file embedded to _form.php (in view)

please help me out.


       for your first problem :

  <?php   if($model->prior_PCI == 1): ?>

        <?php echo $form->labelEx($model,'comments'); ?>

        <?php echo $form->textField($model, 'comments', array('maxlength' => 45)); ?> 

 <?php  endif;  ?>


  1. for your second (in your _form.php) :

           //  you can use the normal html to accomplish :

              <script type="text/javascript" src="<?php echo  $yourJsFileUrl;   ?>"></script>


              <?php  echo CHtml::scriptFile($url); //see the doc (  ?>

 //           use the  CClientScript(in your _form.php or anywhere ):





you must know your js url path ; if it in your web root let 's say : www/js the url may be js/xxx.xx

but if it in your protected dir . you should use assetsManager publish it first then you get the baseUrl please see publish a assets dir