title: Yii Framework: Undefined variable model when checking if guest
body: <p>We have a actionSearchType in our User Controller as follows:</p>
  
  <pre><code>public function actionSearchType()
  {
          if (Yii::app()-&gt;user-&gt;isGuest == true)
              $this-&gt;render('login');
              else 
          $this-&gt;render('search_type');
      }
  </code></pre>
  
  <p>Our actionLogin in our User Controller is as follows:</p>
  
  <pre><code>public function actionLogin()
  {
      $model= new Users();
  
      // if it is ajax validation request
      if(isset($_POST['ajax']))
      {
          echo CActiveForm::validate($model);
          Yii::app()-&gt;end();
      }
   $this-&gt;redirect(Yii::app()-&gt;user-&gt;returnUrl);
                      }
      }
      // display the login form
      $this-&gt;render('login',array('model'=&gt;$model));
  }
  </code></pre>
  
  <p>The goal is to ensure that only authenticated users can execute the options on the search type view.  When I run this page, I receive an error stating <code>Undefined variable: model</code>.</p>
  
  <p>A snippet of the login view is as follows:</p>
  
  <pre><code>&lt;div class="form"&gt;
  &lt;?php $form=$this-&gt;beginWidget('CActiveForm', array(
  'id'=&gt;'login-form',
  'enableClientValidation'=&gt;true,
  'clientOptions'=&gt;array(
      'validateOnSubmit'=&gt;true,
  ),
  )); ?&gt;
  
  &lt;p class="note"&gt;Fields with &lt;span class="required"&gt;*&lt;/span&gt; are required.&lt;/p&gt;
  
  &lt;div class="row"&gt;
      &lt;?php echo $form-&gt;labelEx($model,'username'); ?&gt;
      &lt;?php echo $form-&gt;textField($model,'username'); ?&gt;
      &lt;?php echo $form-&gt;error($model,'username'); ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>What steps must be taken to remedy the above error and properly check to ensure we have an authenticated user?</p>
  
  <p><strong>update</strong>
  I changed actionSearchType to render the Login Widget per below:</p>
  
  <pre><code> public function actionSearchType()
  {
          if (Yii::app()-&gt;user-&gt;isGuest)
              $this-&gt;widget('ext.LoginWidget');
              else 
          $this-&gt;render('search_type');
      }
  </code></pre>
  
  <p>This indeed resolved the error initially seen.  A new problem is that there's no styling of the login widget when it renders.  Should I echo my  tags with appropriate stylesheet classes, or is there a bit more elegant way of doing that?</p>