I have drupal 6.x.

How to programmatically (with a custom module) embed fields of one content type (content type X) in the create/edit form of another content type (content type Y) and store all the data for when the node is created/updated (store X and Y data when Y is stored).

If is not possible this in drupal 6.x I could be to work in drupal 7.x.

Thanks in advance.

2 Answers 2


I think it would be tricky as you would need a way of tracking a relationship between the two nodes as well. You would need to decide on which way the relationship would go if you were to use node reference as its only one way in drupal 6.

This is what I would do 1. Add a node reference field to Y 2. Use hook_form_alter to add the required fields (Embedding cck fields will be tricky better of just sticking to fapi fields) 3. add a custom validation handler for the x fields if required 3. Save x field values as a node programticaly when presave is triggered by hook_node_api http://api.drupal.org/api/drupal/developer!hooks!core.php/function/hook_nodeapi/6
4. Update the noderefrence in Y with the new X nid 5. Use hook_node_api to update X when Y is updated

Another possibility might be to use Rules to create and update for you


http://drupal.org/project/field_reference There's another cck reference field module that should do the same thing for 6 & maybe 7 I cannot recall the name though.

http://drupal.org/project/nodereference_field is different sort of thing where you would create a node that both other nodes could reference which can be nice if your referencing several points of data however there's some bloat to your database & extra time to look up and process the queries from a full node. It's also only v6 so no upgrade path.

http://drupal.org/project/references & http://drupal.org/project/entityreference are the 7+ equivalent of nodereference.

Note: modules aren't what's asked for but they should show you the path if you dissect them.

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.