I have node 1 has a reference to node 2 & node 3 how can I make node 2 & node 3 have a reference automatically (because they have the same reference with node1)?

  • Did you try the Rules module? – Ismini Jun 21 '17 at 8:36

You can implement hook_entity_insert()

Act on entities when inserted.


$entity: The entity object.

$type: The type of entity being inserted (i.e. node, user, comment).

and inside the hook check if you have more than one node in the reference field, in this case you will edit all the nodes and add the reference to the others.

| improve this answer | |
  • Thank you so much !! but I'm not sure how can I do that ? i'm new to The hooks & that stuff?? – MohK Jun 21 '17 at 20:05
  • @MohK Well, you will need to write a little module to do this. – Adrian Cid Almaguer Jun 21 '17 at 20:17
  • @MohK finally do you solve your problem? – Adrian Cid Almaguer Sep 7 '17 at 17:01

You can find a solution that works for me on the following pages: https://www.drupal.org/project/prepopulate/issues/2668010 it is using the module prepopulate and you can find the documentation on this module page.

An other solution is proposed by using the business rule module.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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