I have two nodes 'Runner' and 'Buddy'. I'm using node reference to create a select list of buddies on the runner node.

The Idea is that every runner only has one unique buddy and two runners don't end up with the same buddy.

When editing the runner the buddy select list shows all buddies, I would like it only to show buddies that don't have a runner.

How would I achieve this?


1 Answer 1


Node reference (for Drupal 6) and Entity Reference (for Drupal 7) fields can be configured to use a View to show the available choices.

So, first create a View that shows all buddies that are not related to a runner. Then configure the field that points to the buddy to use that View.

To construct that View you may use the Corresponding Node References. It syncs the node reference between two node types which have a nodereference to each other. WIth this module your View only has to list buddies that have no runner related. This module is for Durpal 6 (I'm guessing your are using Drupal 6), but there's a similar one for D7.

  • Thank you very much @tunic! I thought it should be quite straight forward.
    – th0ward
    Sep 29, 2014 at 18:19
  • You still need to run custom validation in case two people open the form before either has made a selection. The possibility exists that they can then choose the same buddy. Sep 30, 2014 at 7:29
  • Yes, custom valdiation is needed to assure no buddie is assigned to two runners. This validation is tricky because it should be kind of atomic, I mean, check the buddy is avaiable and mark it as unavailable; otherwise someone can pass the validation while buddy is being assigned.
    – sanzante
    Sep 30, 2014 at 8:29
  • Only the site admin will assign buddies to runners, so I don't think this should be a problem.
    – th0ward
    Sep 30, 2014 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.