title: Yii : Undefined variable: nama_unit_kerja
body: <p>I need help. when i open my index it shows that the nama_unit_kerja variable is not defined..
  But i've put them in the SiteController. How can i fix this.</p>
  
  <p>This is my SiteController code :</p>
  
  <pre><code>public function actionIndex()
  {   
      //$this-&gt;layout = "//layouts/adr/main";
      /* $browser = Yii::app()-&gt;browser-&gt;isMobile();
      echo ($browser?'mobile':'not mobile'); exit; */
  
      @session_start();
      Yii::app()-&gt;user-&gt;returnUrl = array('site/index');
      $lang = 'en';
      if(isset($_SESSION['lang'])) $lang = $_SESSION['lang'];
      // renders the view file 'protected/views/site/index.php'
      // using the default layout 'protected/views/layouts/main.php'
      $this-&gt;layout='//layouts/erp/index';
      $modelUnitKerja=new UnitKerja('searchKapTarReal');
      $modelUnitKerja-&gt;unsetAttributes();  // clear any default values
  
      $modelJenisKegiatan=new JenisKegiatan('searchKapTarReal');
      $modelJenisKegiatan-&gt;unsetAttributes();  // clear any default values
  
      //var_dump($_POST);exit;
      if ((isset($_POST['unitKerja'])) or (isset($_POST['year']))){
          if(empty($_POST['unitKerja'])){
              $unitKerja = 0;
          } else {
              $unitKerja = $_POST['unitKerja'];
              $nama_unit_kerja = UnitKerja::model()-&gt;findByAttributes(array("id"=&gt;$_POST['unitKerja']))-&gt;nama_unit_kerja;
          }
          $year = $_POST['year'];
          $year_nm = Year::model()-&gt;findByAttributes(array("id"=&gt;$_POST['year']))-&gt;year;
      }else{
          $unitKerja = 0;
          $year = Year::model()-&gt;findByAttributes(array("year"=&gt;date('Y')))-&gt;id;
          $year_nm = date('Y');
      }
  
      $this-&gt;render('index',array(
          'mJenisKegiatan'=&gt;$modelJenisKegiatan,
          'mUnitKerja'=&gt;$modelUnitKerja,
          'unitKerja'=&gt;$unitKerja,
          'nama_unit_kerja'=&gt;$nama_unit_kerja,
          'year'=&gt;$year,
          'year_nm'=&gt;$year_nm,
      ));
  }
  </code></pre>