本文整理汇总了PHP中CModel::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP CModel::validate方法的具体用法?PHP CModel::validate怎么用?PHP CModel::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CModel
的用法示例。
在下文中一共展示了CModel::validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validates all of the attributes for the current Model. Any attributes that fail validation will additionally get
* logged to the `craft/storage/runtime/logs` folder with a level of LogLevel::Warning.
*
* @param null $attributes
* @param bool $clearErrors
*
* @return bool
*/
public function validate($attributes = null, $clearErrors = true)
{
if (parent::validate($attributes, $clearErrors)) {
return true;
}
foreach ($this->getErrors() as $attribute => $errorMessages) {
foreach ($errorMessages as $errorMessage) {
Craft::log(get_class($this) . '->' . $attribute . ' failed validation: ' . $errorMessage, LogLevel::Warning);
}
}
return false;
}
示例2: validate
/**
* Performs validation on this form and the model.
* clearErrors is not supported, because the model does not support this
* parameter in the RedBeanModel->validate() function.
* Currently this method does not support specifying the $attributes parameter.
*/
public function validate($attributes = null, $clearErrors = true)
{
assert('$clearErrors == true');
assert('$attributes == null');
$formValidatedSuccessfully = parent::validate($attributes);
$modelValidatedSuccessfully = $this->model->validate($attributes, static::shouldIgnoreRequiredValidator());
if (!$modelValidatedSuccessfully || !$formValidatedSuccessfully) {
return false;
}
return true;
}