In CInlineValidator
protected function validateAttribute($object,$attribute)
{
$method=$this->method;
$object->$method($attribute,$this->params);
}
It executed an inline validate method, when the method need to add an error, It have no referentce to the CInlineValidator to use it’s addError method which is:
protected function addError($object,$attribute,$message,$params=array())
{
$params['{attribute}']=$object->getAttributeLabel($attribute);
$object->addError($attribute,strtr($message,$params));
}
Therefore, the placeholder {attribute} won’t be parsed automatically.
One of the solutions I came up is:
In CInlineValidator
protected function validateAttribute($object,$attribute)
{
$method=$this->method;
$object->$method($attribute,$this->params,$this); //we need to pass this $validator
}
And the singnature of the validate method in the model:
validateSomething($attribute,$params,$validator){
$validator->addError($this,$attribute,$params[‘message’],$params=array(’{tok1}’ => ‘val1’) …)
}