xPDOValidator.addMessage
Последнее обновление Jan 28th, 2020 | История страницы | Улучшить эту страницу | Сообщить о проблеме
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$306 per month—let's make that $500!
Learn morexPDOValidator::addMessage¶
Добавить сообщение проверки в стек.
Синтаксис¶
API Doc: http://api.modxcms.com/xpdo/om/xPDOValidator.html#addMessage
void addMessage (string $field, string $name, [mixed $message = null])
Пример¶
Сделайте свою собственную проверку, но все еще используйте объект validator.
$validator = $obj->getValidator();
if ($obj->get('name') == '') {
$validator->addMessage('name','emptyName','Please enter a valid name.');
}
$errors = $validator->getMessages();
foreach ($errors as $error) {
echo 'An error occurred with field "'.$error['name'].'": '.$error['message'];
}
Смотрите также¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$306 per month—let's make that $500!
Learn more