refactored validators.

This commit is contained in:
Qiang Xue
2013-04-05 10:21:43 -04:00
parent ae6c69fc8f
commit 52a160cb7b
4 changed files with 91 additions and 127 deletions

View File

@ -245,8 +245,9 @@ abstract class Validator extends Component
*/
public function addError($object, $attribute, $message, $params = array())
{
$value = $object->$attribute;
$params['{attribute}'] = $object->getAttributeLabel($attribute);
$params['{value}'] = $object->$attribute;
$params['{value}'] = is_array($value) ? 'array()' : $value;
$object->addError($attribute, strtr($message, $params));
}