1

I need to generate a node of a dependent content type when creating a node of the primary content type.

I have successfully created the function to be called and attached it to the form and it creates the node as desired, but since the function that generates the secondary node runs first, it cannot be populated with the node id of the primary node, nor with any other data elements from the primary node.

How do I ensure that the submit handlers are executed in the proper order?

   $form['#submit'][] = 'nttac_custom_tta_submit';
   $form['actions']['submit']['#submit'][] .= 'nttac_custom_tta_submit';
   $form['actions']['submit']['#submit'][] = array('node_form_submit','nttac_custom_tta_submit');

None of the above methods seem to work although they do get the handlers in the proper order

2 Answers 2

2

All the methods you have mentioned should be calling your custom submit handler at the end. However check your $form array when the page is loaded to confirm your custom submit handler is at the right place.

If not try

MYMODULE_entity_insert($entity, $type) {

//Paste your secondary node creation code here

}

See https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_entity_insert/7 for more details on this hook

0

you should user a hook instead :

https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_submit/7

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.