0

I am in D6 and need to modify a table entry of a content type field (content_field_p_fieldname) after node submit . What i done is wrote a hook_form_alter and written a code to update in it . This works fine , but problem is : because of node revision works everytime on node edit it creates a revision and creates a new table entry ,and i can update the second last entry only . I found out the cause as 'Node is creating revision after hook_form_alter' . Any solution on how to i update after node creating the revision , I tried hook_node_insert but with no luck .

/*
 * implementation of hook_form_alter
 */
function module_form_alter(&$form, $form_state, $form_id) {
    if (isset($form['#node']) && isset($form_id)){            
        $node = $form['#node'];
        if (isset($form_id)){
            if($form_id == 'p1_request_node_form' || $form_id == 'p2_request_node_form' ) {
                   $form['#submit'][] = 'auto_ip_submit';                                
            }
            else if($form_id == 'ip_range_node_form'){
                    $form['#submit'][] = 'ip_range_submit';
        }
    } 
 } 

}

and in

     function auto_ip_submit(&$form, $form_state) {   
        // stuff to update the table field data
      }

But this works only after the revision of node .

  • 1
    May be the first answer can help you drupal.stackexchange.com/questions/28456/… – NTT Aug 26 '16 at 11:43
  • It does not provide where to write the code , in form_alter ? – Crazyrubixfan Aug 26 '16 at 12:05
  • That's is possible but only if you have the nodeid available so you can set the node elements good before saving and editing. – Justme Aug 26 '16 at 12:33
  • @Justme didint get you – Crazyrubixfan Aug 26 '16 at 12:49

Your Answer

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

Browse other questions tagged or ask your own question.