protected function attemptToSaveModelFromPost($model, $redirectUrlParams = null, $redirect = true, $returnOnValidate = false)
 {
     assert('$redirectUrlParams == null || is_array($redirectUrlParams)');
     $postVariableName = get_class($model);
     if (isset($_POST[$postVariableName])) {
         $model->setAttributes($_POST[$postVariableName]);
         $currencyHelper = Yii::app()->currencyHelper;
         if ($model->id > 0) {
             $categories = Category::getCategoryByNameEdit($model->name, $model->id);
         } else {
             $categories = Category::getCategoryByName($model->name);
         }
         if ($categories != null) {
             $model->addError('name', Zurmo::t('Core', 'Name Already Exists'));
             $currencyHelper->resetErrors();
             return $model;
         }
         if ($model->save()) {
             $this->redirectAfterSaveModel($model->id, $redirectUrlParams);
         }
     }
     return $model;
 }