You are here

function nodeapi_example_node_validate in Examples for Developers 7

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

nodeapi_example/nodeapi_example.module, line 95
Module implementation for nodeapi_example module.

Code

function nodeapi_example_node_validate($node, $form) {
  if (variable_get('nodeapi_example_node_type_' . $node->type, FALSE)) {
    if (isset($node->nodeapi_example_rating) && !$node->nodeapi_example_rating) {
      form_set_error('nodeapi_example_rating', t('You must rate this content.'));
    }
  }
}