Inside my luvlyricshelper_nodeapi function I have this:

switch ($op) {
    case 'validate':
      luvlyricshelper_validate_lyrics();
      break;
    ..more code

then I have:

function luvlyricshelper_validate_lyrics() {
  drupal_set_message('here: <pre>'. print_r($node, TRUE) .'</pre>');
  drupal_set_message('here: <pre>'. print_r($form_values, TRUE) .'</pre>');
  drupal_set_message('node type is '. $node->type);
  $type = 'lyrics';
  if ($node->type == $type) {
    drupal_set_message("node type is lyrics");
    ... more code

For some reason, the $node object seems to be empty as well as $form_values

I also never get the message "node type is lyrics". What's going on here?

Comments

nevets’s picture

PHP variables are by default local to a function so if you want $node and $form_values available to the function change the function call to

luvlyricshelper_validate_lyrics($node, $form_values);

and the function declaration to

function luvlyricshelper_validate_lyrics($node, $form_values) {
wmclark’s picture

Hah,

Thanks, I earned the noob stamp!

Thank you nevets