Beispiel #1
0
 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aBoardMember !== null) {
             if (!$this->aBoardMember->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aBoardMember->getValidationFailures());
             }
         }
         if ($this->aCommittee !== null) {
             if (!$this->aCommittee->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aCommittee->getValidationFailures());
             }
         }
         if (($retval = BoardCommitteePeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Committee();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Committee'])) {
         $model->attributes = $_POST['Committee'];
         $model->members = implode(',', $model->members);
         if ($model->save() && $model->validate()) {
             date_default_timezone_set("Asia/Manila");
             $activity = new Activity();
             $activity->act_desc = 'Added a Committee';
             $activity->act_datetime = date('Y-m-d G:i:s');
             $activity->act_by = User::model()->findByPK(Yii::app()->user->name)->emp_id;
             $activity->save();
             $this->redirect(array('view', 'id' => $model->comm_id));
         }
     }
     $this->render('create', array('model' => $model));
 }