Example #1
0
 /**
  * Override to handle userStatus validation
  * @param User | ModelForm $model
  * @param string $postVariableName
  */
 protected function attemptToValidateAjaxFromPost($model, $postVariableName)
 {
     if (isset($_POST['ajax']) && $_POST['ajax'] == 'edit-form') {
         $model->setAttributes($_POST[$postVariableName]);
         $model->validate();
         $userStatus = UserStatusUtil::makeByPostData($_POST[$postVariableName]);
         if ($model instanceof User) {
             if ($userStatus == null) {
                 $userStatus = UserStatusUtil::makeByUser($model);
             }
             Yii::app()->licenseManager->resolveValidationOnCreateOrEditUser($model, $userStatus);
         } elseif ($model instanceof ModelForm) {
             if ($userStatus == null) {
                 $userStatus = UserStatusUtil::makeByUser($model->getModel());
             }
             Yii::app()->licenseManager->resolveValidationOnCreateOrEditUser($model->getModel(), $userStatus);
         }
         $errorData = ZurmoActiveForm::makeErrorsDataAndResolveForOwnedModelAttributes($model);
         echo CJSON::encode($errorData);
         Yii::app()->end(0, false);
     }
 }