I have content type "article", in some cases I need to orginise group of parent and child nodes and to do this I use Node Reference from URL module. Also I need to include parent node in this group of articles because some views and node URL depend on completed field "node reference". So, how it works now:

  1. I create a parent node and leave the node reference field empty as the parent node doesn't exist now;
  2. Save this node
  3. Back to edit page and choose my new parent node from the list of avalible nodes in node reference field;

What I would like to do is to create parent node and fill node reference field at the same time.

I guess that Rules module could help me but It too powerfull module and I do not need it for my website. Is there a more simple solution?

  • Why can't you create parent node first? Dec 6, 2012 at 9:35
  • yes, I do that at first but I need to have filled node reference field filled with the link to itself. I mean that if parent node "Node 1" the node reference field have the same value "Node 1" it should not be empty
    – moto
    Dec 6, 2012 at 9:38

2 Answers 2


Use hook_node_insert and update the node.

  • OP is not using Drupal 6
    – niksmac
    Dec 6, 2012 at 10:22
  • @NikhilM which OP? Dec 6, 2012 at 10:35
  • OP one who originally posted the question.
    – niksmac
    Dec 6, 2012 at 10:39
  • oh ya ya.. it is different function in 7... sorry but I think he can understand what I want to say. Dec 6, 2012 at 10:42
  • I changed it now.. thnx.. Dec 6, 2012 at 10:44

Depending on which relationship module you're using there are different options.

  • If you're using Entity Reference there's the Inline Entity Form module:

    Provides a widget for inline management (creation, modification, removal) of referenced entities. The primary use case is the parent -> children one (product display -> products, order -> line items, etc.), where the child entities are never managed outside the parent form.

  • If you're using the References module there's References Dialog:

    This module extends reference fields like the user and node reference fields by adding links to add, edit and search for references through a dialog. This allows for a workflow where the user can create all the references to a node at the same time as she is creating it, a process which sometimes get's a bit backwards, when a user for instance needs to create all the facts for an article.

Both will allow you to create a referenced node at the same time as creating the referee.

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.