I am really hoping someone might have an insight into this really troubling issue. I have got a custom node form which is presented as 4 multistep pages. In my third step, I have a bunch of ajax buttons which allow the user to save information. The problem is, after the ajax button has been clicked and we click the next 'page' button, all the $form_state['node'] values from the previous pages are being lost. So, consequently, when I get to hook_node_insert, I have empty values from the first 3 pages.

However, the weird thing is, this only happens in a couple of my ajax buttons in that page. I have a few other ajax buttons, which, don't cause any such problem. This is the definition for one of the problematic buttons:

    //Add the cancel button to cancel the "Add New Product" form
    $form['newproduct']['fieldset']['cancel'] = array(
      '#type' => 'button',
      '#name' => 'Add New Product Cancel',
      '#value' => 'Cancel',
      '#ajax' => array(
        'callback' => 'MyModule_NewProduct_Cancel_ajax_callback',
        'wrapper' => 'MyModule_NewProduct_wrapper',
        'method' => 'replace',
      '#limit_validation_errors' => array(),
      '#submit' => array(),

This is the callback for that button:

function MyModule_NewProduct_Cancel_ajax_callback($form, &$form_state) {
  //Return the add new product button
  return $form['newproduct']['addnewproduct'];

I know that I might not have included enough code to see the full problem, but was wondering if there was any problem with the my ajax button element definition. Would appreciate any help on this. Thank you.

Update!! - SOLVED - It was a limit_validation_errors problem. I didn't have that set for my 'next' buttons in hook_form_formid_alter().

  • Digressing to suggest a better solution. The best way (easy and with powerful functionality) to create a multi step node add form (or any form), is using CTools. Check this out and see if you would rather wanna use it than going for a custom functionality - fuseinteractive.ca/blog/… Commented Jun 18, 2012 at 9:05
  • FYI you should write your solution as an answer and accept it rather than editing the title. Accepting your own answer is fine if it solved your problem :-)
    – Chapabu
    Commented Jul 3, 2012 at 10:56

1 Answer 1


You need to add a submit handler that has

$form_state['rebuild'] = TRUE;

Otherwise the form will actually submit, and the form_state values will be purged.

  • I already have a $form_state['rebuild'] = TRUE; on another ajax button's submit function, but that button is also causing the same problem. My form_state['node'] values are being after that button is clicked as well.
    – SN_26
    Commented Jun 19, 2012 at 6:21
  • @Supergirl26 Please update your code in the question to show that then.
    – googletorp
    Commented Jun 20, 2012 at 9:52
  • @Supergirl26 Update your question, don't post details like this in comments, as they get lost and aren't formatted the same way.
    – googletorp
    Commented Jun 21, 2012 at 9:17

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.