title: Yii: Access CActiveForm.htmlOptions from controller when form is submitted to change css visibility
body: <p>I have a CActiveForm which when submitted should make a second CActiveForm become visible. I know how to change the htmlOptions of the form when its created but not how to access it via the controller. </p>
  
  <p>My View with two forms. The second form has visibility:hidden</p>
  
  <pre><code>&lt;div class="form"&gt;
              &lt;?php
              $numberForm = $this-&gt;beginWidget('CActiveForm', array(
                  'id' =&gt; 'addnumber-form',
                  'enableAjaxValidation' =&gt; true,
                  'clientOptions' =&gt; array(
                      'validateOnSubmit' =&gt; true,
                  ),
                      ));
              ?&gt;
  
              &lt;p class="note"&gt;&lt;?php echo UserModule::t('Fields with &lt;span class="required"&gt;*&lt;/span&gt; are required.'); ?&gt;&lt;/p&gt;
              &lt;?php echo $numberForm-&gt;errorSummary($numberModel); ?&gt;
  
              &lt;div class="row"&gt;
                  &lt;?php echo $numberForm-&gt;labelEx($numberModel, 'number'); ?&gt;
                  &lt;?php echo $numberForm-&gt;textField($numberModel, 'number'); ?&gt;
                  &lt;?php echo $numberForm-&gt;error($numberModel, 'number'); ?&gt;
  
                  &lt;?php
                  echo CHtml::submitButton(UserModule::t("Verify"), array(
                      "class" =&gt; "btn btn-success"
                  ));
                  ?&gt;
  
              &lt;/div&gt;
  
              &lt;?php $this-&gt;endWidget(); ?&gt;
  
              &lt;?php
              $verifyForm = $this-&gt;beginWidget('CActiveForm', array(
                      'id' =&gt; 'verify-form',
                      'enableAjaxValidation' =&gt; true,
                      'clientOptions' =&gt; array(
                          'validateOnSubmit' =&gt; true,
                      ),
                      'htmlOptions' =&gt; array("style"=&gt;"visibility: hidden"),
                  ));
              ?&gt;
  
              &lt;?php echo $verifyForm-&gt;errorSummary($verifyModel); ?&gt;
  
              &lt;p&gt;A authorisation code has been sent to your phone. Please enter it below. If you don't receive a text message make sure you entered your number correctly and try again&lt;/p&gt;
  
              &lt;div class="row"&gt;
                  &lt;?php echo $verifyForm-&gt;labelEx($verifyModel, 'authcodeUser'); ?&gt;
                  &lt;?php echo $verifyForm-&gt;textField($verifyModel, 'authcodeUser'); ?&gt;
                  &lt;?php echo $verifyForm-&gt;error($verifyModel, 'authcodeUser'); ?&gt;
  
                  &lt;?php
                  echo CHtml::submitButton(UserModule::t("Confirm"), array(
                      "class" =&gt; "btn btn-success"
                  ));
                  ?&gt;
  
                  &lt;?php
                      foreach(Yii::app()-&gt;user-&gt;getFlashes() as $key =&gt; $message) {
                          echo '&lt;div class="flash-' . $key . '"&gt;' . $message . "&lt;/div&gt;\n";
                      }
                  ?&gt;
  
              &lt;/div&gt;
  
              &lt;?php $this-&gt;endWidget(); ?&gt;
  
  
          &lt;/div&gt;&lt;!-- form --&gt; 
  </code></pre>
  
  <p>My controller for these forms</p>
  
  <pre><code>public function actionAddnumber(){
      $numberModel = new UserAddNumber;
      $verifyModel = new UserVerifyNumber;
      if (Yii::app()-&gt;user-&gt;id) {
  
          // ajax validator
          if(isset($_POST['ajax']) &amp;&amp; $_POST['ajax']==='addnumber-form')
          {
              echo UActiveForm::validate($numberModel);
              Yii::app()-&gt;end();
          }
  
          if(isset($_POST['UserAddNumber'])) {
                  $numberModel-&gt;attributes=$_POST['UserAddNumber'];
                  if($numberModel-&gt;validate()) {
                      $profile = Profile::model()-&gt;findByAttributes(array('user_id'=&gt;Yii::app()-&gt;user-&gt;id));
                      $profile-&gt;mobileNo = $numberModel-&gt;number;
                      $profile-&gt;save();
  
                      //MAKE $verifyForm visibility to visible uring htmlOptions
  
                      Yii::app()-&gt;session['authcode'] = '4444';
                  }
          }
  
          if(isset($_POST['UserVerifyNumber'])) {
                  $verifyModel-&gt;attributes=$_POST['UserVerifyNumber'];
                  if($verifyModel-&gt;validate()) {
                      $profile = Profile::model()-&gt;findByAttributes(array('user_id'=&gt;Yii::app()-&gt;user-&gt;id));
                      $profile-&gt;mobileNoVerified = True;
                      $profile-&gt;save();
                      Yii::app()-&gt;user-&gt;setFlash('profileMessage',UserModule::t("Your mobile number has been verified"));
                      $this-&gt;redirect(array("profile"));
  
                  }
          }
  
      }
      $this-&gt;render('addnumber', array('numberModel'=&gt;$numberModel, 'verifyModel' =&gt; $verifyModel));
  }
  </code></pre>