1 nodeapi_example.module nodeapi_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/nodeapi_example/nodeapi_example.module, line 105
Module implementation for nodeapi_example module.

Code

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