0

I've unshifted my own submit handler to the #submit handler of a node form. I already have a validation handler, so I can't execute my cancelling submit handler there.

Maybe this makes more sense:

  1. my validation
  2. all other validation
  3. my submit handler, which potentially kills the submit process to form_state[rebuild] => TRUE and try again
  4. all other submit handlers

Is that possible? I can cancel submission if I put my submit logic in a validation, but that's too soon. It should only run when all validation passes.

  • 1
    This sounds like an interesting question, but I can't quite follow what you are trying to accomplish? Can you provide a little background as to what you need to do? – mpdonadio Mar 28 '12 at 13:27
2

Ensure that your implementation of hook_form_alter() is the last one to be called. Your implementation of hook_form_alter() can then unshift one validation function and push a second validation function. The second validation function would then have complete information about whether other validation functions objected to saving the node (by calling form_get_errors()).

You can ensure that your your implementation of hook_form_alter() is the last one to be called by implementing hook_module_implements_alter()

  • DUH! Two validation functions! OMG I suck. My module has a high weight, so it'll be last. Thanks man. – Rudie Mar 29 '12 at 21:53

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.