Example #1
0
 /**
  * beforeValidate
  *
  */
 public function beforeValidate($options = array())
 {
     $errorMessages = Hash::merge($this->getValidationMessages(), ['customCheck' => __('Validation Error: customCheck')]);
     parent::beforeValidate($options);
     $this->setValidationPatterns();
     $this->setErrorMessageI18n($errorMessages, false);
     $this->replaceValidationErrorMessagesI18n();
 }
Example #2
0
 function beforeValidate()
 {
     if (!empty($this->data)) {
         foreach ($this->data as $model => $data_array) {
             foreach ($data_array as $field => $value) {
                 if (strpos($field, 'date') !== false) {
                     $this->data[$model][$field] = $this->dateFormatBeforeSave($value);
                 }
             }
         }
     }
     parent::beforeValidate();
     return true;
 }
Example #3
0
 /**
  * enables HABTM-Validation
  * e.g. with
  * 'rule' => array('multiple',array('min' => 2))
  * 2010-01-14 ms
  */
 public function beforeValidate($options = array())
 {
     foreach ($this->hasAndBelongsToMany as $k => $v) {
         if (isset($this->data[$k][$k])) {
             $this->data[$this->alias][$k] = $this->data[$k][$k];
         }
     }
     parent::beforeValidate($options);
 }
Example #4
0
 /**
  * Updates validation errors if there was an error uploading the file.
  * presents the user the errors.
  */
 function beforeValidate(Model $Model, $options = array())
 {
     if (isset($Model->data[$Model->alias][$this->options[$Model->alias]['fileVar']])) {
         $file = $Model->data[$Model->alias][$this->options[$Model->alias]['fileVar']];
         $this->Uploader[$Model->alias]->file = $file;
         if ($this->Uploader[$Model->alias]->hasUpload()) {
             if ($this->Uploader[$Model->alias]->checkFile() && $this->Uploader[$Model->alias]->checkType() && $this->Uploader[$Model->alias]->checkSize()) {
                 $Model->beforeValidate();
             } else {
                 $Model->validationErrors[$this->options[$Model->alias]['fileVar']] = $this->Uploader[$Model->alias]->showErrors();
             }
         } else {
             if (isset($this->options[$Model->alias]['required']) && $this->options[$Model->alias]['required']) {
                 $Model->validationErrors[$this->options[$Model->alias]['fileVar']] = 'Select file to upload';
             }
         }
     } elseif (isset($this->options[$Model->alias]['required']) && $this->options[$Model->alias]['required']) {
         $Model->validationErrors[$this->options[$Model->alias]['fileVar']] = 'No File';
     }
     return $Model->beforeValidate();
 }