xPDOValidator.addMessage
xPDOValidator::addMessage
Add a validation message to the stack.
Syntax
API Doc: http://api.modxcms.com/xpdo/om/xPDOValidator.html#addMessage
void addMessage (string $field, string $name, [mixed $message = null])
Example
Do our own validation, but still use the validator object.
$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']; }
See Also
Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab).