title: undefined variable model in yii
body: <p>I am getting the error <code>undefined variable model</code>. I have the following codes in my view and controller. My aim is to search the results and show it in same page. I have tried the following things but its not working.</p>
  
  <p>Again,I this this the conventional yii method to do so,or do I have to use a search() function from model SearchEmployee().?</p>
  
  <pre><code>public function actionSearch()
  {
        $model = new SearchEmployee();
  
         /*Getting Data From Search Form For Processing */
    if (isset($_POST['SearchEmployee'])) {
  
        $category   =  $_POST['SearchEmployee']['category_id'];
        $skills     =  $_POST['SearchEmployee']['skills'];
        $experience =  $_POST['SearchEmployee']['experience'];
  
        $model = SearchEmployee::model()-&gt;find(array(
        'select' =&gt; array('*'), "condition" =&gt; "category_id=$category AND key_skills like '%$skills%' AND experience=$experience",
        ));
  
        $this-&gt;render('search',$model);
    }
  
    /*Getting Data From Search Form For Processing */
    $this-&gt;render('search', array('model' =&gt; $model));
  }
  </code></pre>
  
  <p>In View Section: search.php//To display and search the desired result</p>
  
  <pre><code>&lt;div class="row"&gt;
     &lt;?php echo $form-&gt;labelEx($model,'Category'); ?&gt;
     &lt;?php echo $form-&gt;dropDownList($model,'category_id',$list,array('empty' =&gt;'(Select a Category')); ?&gt;
     &lt;?php echo $form-&gt;error($model,'category'); ?&gt;
  &lt;/div&gt;
  
    &lt;div class="row"&gt;
  &lt;?php echo $form-&gt;labelEx($model,'Experience'); ?&gt;
      &lt;?php echo $form-&gt;textField($model,'experience'); ?&gt;
      &lt;?php echo $form-&gt;error($model,'experience'); ?&gt;    
  &lt;/div&gt;
  
  
  &lt;div class="row buttons"&gt;
    &lt;?php echo CHtml::submitButton('Search'); ?&gt;
  &lt;/div&gt;
  
  
  
  &lt;div class="view"&gt;
  
    &lt;h1&gt;Results &lt;/h1&gt;
  
    &lt;div class="view" id="id"&gt;
  
       &lt;h1&gt; Records Display &lt;/h1&gt;
  
       &lt;h4&gt;Name:        &lt;?php echo $form-&gt;labelEx($model,'name'); ?&gt;&lt;/h4&gt;
       &lt;h4&gt;Skills:      &lt;?php echo $form-&gt;labelEx($model,'experience'); ?&gt;&lt;/h4&gt;
       &lt;h4&gt;Experience:  &lt;?php echo $form-&gt;labelEx($model,'skills'); ?&gt;&lt;/h4&gt;
       &lt;h5&gt;&amp;nbsp;&amp;nbsp ;&lt;?php echo $form-&gt;labelEx('VIew Details'); ?&gt;&lt;/h5&gt;
     &lt;/div&gt;
  
   &lt;/div&gt;
  </code></pre>
  
  <p>In view section I am using the search and view results option in the same form.I am getting the error after clicking the search button.Is this the correct way to do </p>