hey, guys!
i need some input values not to be negative, like prices and discount values, so i created a custom validation function to check the rule, as following:
public function notNegative($attribute){
if (0 > $this->$attribute):
$message = Yii::t('yii', '{attribute} cannot be negative!', array('attribute'=>$attribute));
$this->addError($attribute,$message);
endif;
}
in rules, i have so:
...
array('offerPriceInCash','notNegative'),
...
ok, valitation till now works, but i can’t figure out how to get the attribute label instead of the attribute name in the error message…i’ve created the translation in my yii.php message file and i’m getting something similar to
{offerPriceInCash} não pode ser negativo! --> note that Yii::t() translates the message correctly, but what about attribute label?
could somebody please give me a hand on thhis? am i missing something?
thanks in advance!
regards!