1 node_hooks_example.module | node_hooks_example_node_validate($node, $form) |
Implements hook_node_validate().
Check that the rating attribute is set in the form submission, since the field is required. If not, send error message.
Related topics
File
- modules/
examples/ node_hooks_example/ node_hooks_example.module, line 94 - Hook implementations for the Node Hooks Example module.
Code
function node_hooks_example_node_validate($node, $form) {
if (config_get('node_hooks_example.settings', 'node_hooks_example_node_type_' . $node->type)) {
if (isset($node->node_hooks_example_rating) && !$node->node_hooks_example_rating) {
form_set_error('node_hooks_example_rating', t('You must rate this content.'));
}
}
}