By Spider84 on
Hello.
I am using hook_node_presave in my module. How can I stop the node saving process and execute intead this some custom coode using this hook.
Thanks.
Hello.
I am using hook_node_presave in my module. How can I stop the node saving process and execute intead this some custom coode using this hook.
Thanks.
Comments
You can execute your code
You can execute your code inside your implementation of hook_node_presave:
Are you saying you don't want to save the node?
- Brendan
Yes. I want to check some
Yes.
I want to check some condition and execute some code WITHOUT saving the node(I will do some very customized node saving).
I have found one way to stop the saving process - to make a redirect.
But may be there is a more correct way?
There's always a lot of ways
There's always a lot of ways to do things in Drupal. I would go about it by altering the node edit form with hook_form_alter and have it submit to my own function instead of the standard:
This way you are not trying to stop the save process which is already in progress, but you are stopping it before it starts. You'll also be dealing with just the form values and not a fully assembled node which might be easier or harder for you to work with depending.
- Brendan
Thank you very much! It is
Thank you very much! It is just what I need.
Sorry for writing in this
Sorry for writing in this topic again. Can I see the code of default Submit handler?
In your hook print the
In your hook print the contents of:
This will give you a list of the submit handlers on the form. Searching for those functions will show you all the code that is run by default.
Cheers
Tom