How do I check for a nodereference field in a custom node form in Drupal 6?

I have a nodereference auto-completion field (field_hostnamelastref) in a custom pass-node-form.tpl.php. The field refers to four elements (last name, first name, id and status) generated from tokens in autoplay from a different content type.

When entering a name in the nodereference field, if the corresponding status for that last name is "SUSPENDED", I would like to be able to validate that field with an error message and block form submission.

This is my first attempt at writing my own validation and I had no luck. Have tried many different ways: ereg, preg-match and strpos. Below is my latest attempt:

<?php
  function pass_validate($form_id,$form_values) {
    $status = 'SUSPENDED';
    if (strpos ($form_values['hostnamelastref'], $status)) {
      form_set_error('hostnamelastref', t('The account for this person has been suspended.', array('@type' => $type->name)));
    }
  }
?>

      

Not sure if I'm even in the park. Any help is greatly appreciated!

0


a source to share


1 answer


If you can pass SUSPENDED information in any way in views, you can restrict the nodes that you select in nodereference using the view. Then nodereference will follow the check if the user entered a node not in the list.



But I'm not sure I understood your question.

0


a source







All Articles