hook_validate
developer/hooks/node.php, строка 379
- Версии
- 5 – 6
hook_validate($node, &$form)
Проверяет форму редактирования ноды.
This is a hook used by node modules. It is called to allow the module
to verify that the node is in a format valid to post to the site.
Errors should be set with form_set_error()
.
To validate nodes of all types (not just nodes of the type(s) defined by
this module), use hook_nodeapi()
instead.
Changes made to the $node
object within a hook_validate()
function will
have no effect. The preferred method to change a node's content is to use
hook_submit()
or hook_nodeapi($op
='submit') instead. If it is really
necessary to change the node at the validate stage, you can use function
form_set_value()
.
Подробный пример использования смотрите в node_example.module.
Параметры
$node
The node to be validated.
$form
The node edit form array.
Возвращаемое значение
Нет.
Связанные темы
Код
<?php
function hook_validate($node, &$form) {
if (isset($node->end) && isset($node->start)) {
if ($node->start > $node->end) {
form_set_error('time', t('An event may not end before it starts.'));
}
}
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии