/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($personid)
 {
     $model = new Personbenefits();
     $model->PersonID = intval($personid);
     $valid = true;
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Personbenefits'])) {
         $model->attributes = $_POST["Personbenefits"];
         $valid = $model->validate() && $valid;
         if ($valid && $model->save()) {
             $person = Person::model()->findByPk($model->PersonID);
             echo CJSON::encode(array("result" => "success", "data" => $this->renderPartial("//person/tabs/_benefits", array('models' => $person->benefits, "personid" => $model->PersonID), true)));
         } else {
             echo CJSON::encode(array("result" => "error", "data" => $this->renderPartial('_form', array('model' => $model), true)));
         }
         Yii::app()->end();
     }
     $this->renderPartial('_Modal', array('model' => $model, true));
 }