hasErrors($attribute)) { $errors = $object->getErrors($attribute); $object->clearErrors($attribute); } $this->compareValue = $this->minDate; $this->operator = '>='; parent::validateAttribute($object, $attribute); $this->compareValue = $this->maxDate; $this->operator = '<='; parent::validateAttribute($object, $attribute); $addRangeError = false; if ($object->hasErrors($attribute)) { $object->clearErrors($attribute); $addRangeError = true; } if (!empty($errors)) { $object->addErrors($errors); } if ($addRangeError) { $message = $this->message !== null ? $this->message : Yii::t('astaf', 'The value of {attribute} ({value}) is not between {minDate} and {maxDate}.'); $this->addError($object, $attribute, $message, array('{operator}'=>$this->operator, '{minDate}'=>$this->minDate, '{value}'=>$object->$attribute, '{maxDate}'=>$this->maxDate)); } } }