Jump to main content Jump to doc navigation

xPDOValidator::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'];
}

Смотрите также

  1. xPDOValidator.addMessage
  2. xPDOValidator.getMessages
  3. xPDOValidator.hasMessages
  4. xPDOValidator.validate

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

  • modmore
  • STERC
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Dannevang Digital
  • Sepia River Studios
  • Chris Fickling
  • CrewMark
  • deJaya
  • eydolan
  • Following Sea
  • Lefthandmedia
  • Murray Wood
  • Anton Tarasov
  • Stéphane Jäggi
  • Raffy
  • Snow Creative
  • Nick Clark
  • A. Moreno
  • JT Skaggs
  • Helen
  • YJ
  • krisznet
  • Richard
  • Yanni

Budget

$311 per month—let's make that $500!

Learn more