'; public $compareAttribute; public $compareValue; /** * Validates the attribute of the object. * If there is any error, the error message is added to the object. * @param CModel $object the object being validated * @param string $attribute the attribute being validated */ protected function validateAttribute($object, $attribute) { if ((empty($this->compareAttribute) && empty($this->compareValue)) || empty($this->operator)) { $this->addError($attribute, 'Invalid Parameters to dateCompare'); } $compareAttribute = $this->compareAttribute; $this->compareValue = empty($compareAttribute) ? $this->compareValue : $object->$compareAttribute;; if ($this->allowEmpty && empty($this->compareValue)) { return; } $start = CDateTimeParser::parse($object->$attribute, $this->format); $end = CDateTimeParser::parse($this->compareValue, $this->format); //a little php trick - safe than eval and easier than a big switch statement if (version_compare($start, $end, $this->operator)) { return; } else { $message = $this->message !== null ? $this->message : Yii::t('astaf', 'The value of {attribute} ({value}) is not {operator} {compareAttribute} ({compareValue}).'); $this->addError($object, $attribute, $message, array('{operator}'=>$this->operator, '{compareValue}'=>$this->compareValue, '{value}'=>$object->$attribute, '{compareAttribute}'=>($object->getAttributeLabel($this->compareAttribute)))); } } }