本文整理汇总了PHP中CValidator::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP CValidator::addError方法的具体用法?PHP CValidator::addError怎么用?PHP CValidator::addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CValidator
的用法示例。
在下文中一共展示了CValidator::addError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addErrorInternal
/**
* Adds an error about the specified attribute to the active record.
* This is a helper method that call addError which performs message selection and internationalization.
*
* Construct the message and the params array to call addError().
*
* @param CModel $object the data object being validated
* @param string $attribute the attribute being validated
* @param string $tested_param the tested property (eg 'upper case') for generating the error message
* @param array $values values for the placeholders :is and :should in the error message - array(['found'] => <int>, ['required'] => <int>)
*/
private function addErrorInternal($object, $attribute, $tested_param, array $values)
{
$message = "Mật khẩu không chứa đủ kí tự :tested_param. Mật khẩu ít nhất phải chứa :required kí tự :tested_param.";
$params = array(':attribute' => $attribute, ':tested_param' => $tested_param, ':found' => $values['found'], ':required' => $values['required']);
parent::addError($object, $attribute, $message, $params);
}
示例2: addErrorInternal
/**
* Adds an error about the specified attribute to the active record.
* This is a helper method that call addError which performs message selection and internationalization.
*
* Construct the message and the params array to call addError().
*
* @param CModel $object the data object being validated
* @param string $attribute the attribute being validated
* @param string $tested_param the tested property (eg 'upper case') for generating the error message
* @param array $values values for the placeholders :is and :should in the error message - array(['found'] => <int>, ['required'] => <int>)
*/
private function addErrorInternal($object, $attribute, $tested_param, array $values)
{
$message = Yii::t(__CLASS__ . '.' . __CLASS__, '{attribute} doesn\'t contain enough {tested_param}. {found} found whereas it must be at least {required}.');
$params = array('{tested_param}' => $tested_param, '{found}' => $values['found'], '{required}' => $values['required']);
parent::addError($object, $attribute, $message, $params);
}