/**
  * Edit a publisher.
  */
 public function actionEdit($id = 0)
 {
     if ($id > 0) {
         $model = Publisher::model()->findByPk($id);
     } else {
         $model = new Publisher();
     }
     if (isset($_POST['Publisher'])) {
         $model->attributes = $_POST['Publisher'];
         if ($model->validate() && $model->save()) {
             Yii::app()->user->setFlash('successmsg', 'The changes have been saved.');
             $this->redirect('/publisher/index');
         } else {
             Yii::app()->user->setFlash('errormsg', 'Error saving the publisher page.');
             $this->render('edit', array('model' => $model, 'id' => $id));
         }
     } else {
         $this->render('edit', array('model' => $model, 'id' => $id));
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Publisher();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Publisher'])) {
         $model->attributes = $_POST['Publisher'];
         if ($model->validate()) {
             if ($model->save()) {
                 Yii::app()->clientScript->scriptMap['jquery.js'] = false;
                 echo CJSON::encode(array('status' => 'success', 'div' => "<div class=alert alert-info fade in>Successfully added ! </div>"));
                 Yii::app()->end();
             }
         }
     }
     if (Yii::app()->request->isAjaxRequest) {
         $cs = Yii::app()->clientScript;
         $cs->scriptMap = array('jquery.js' => false, 'bootstrap.js' => false, 'jquery.min.js' => false, 'bootstrap.notify.js' => false, 'bootstrap.bootbox.min.js' => false);
         echo CJSON::encode(array('status' => 'render', 'div' => $this->renderPartial('_form', array('model' => $model), true, false)));
         Yii::app()->end();
     } else {
         $this->render('create', array('model' => $model));
     }
 }