/** * Validates a single attribute. * This method should be overridden by child classes. * @param CModel $object the data object being validated * @param string $attribute the name of the attribute to be validated. */ protected function validateAttribute($object, $attribute) { if ($object->{$this->needFileMethodName}() && empty($object->{$attribute})) { $object->addError($attribute, "Необходимо заполнить поле {$object->getAttributeLabel($attribute)}"); } }
/** * Adds an error about the specified attribute to the active record. * This is a helper method that performs message selection and internationalization. * @param CModel $object the data object being validated * @param string $attribute the attribute being validated * @param string $message the error message * @param array $params values for the placeholders in the error message */ protected function addError($object, $attribute, $message, $params = array()) { $params['{attribute}'] = $object->getAttributeLabel($attribute); $object->addError($attribute, strtr($message, $params)); }