Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.Hi,
I have one use case. I need to redirect user to confirmation form when they saves the node. I have tried in below ways, but which didn't work for me.
Approach 1:
- In hook_form_alter, I have added new submit function by array_unshift(). When my submit function getting call, I am redirecting that user to my confirmation form.
- When it get redirect, the content is getting save and then its getting redirect
- I need to redirect node, before it get save.
Approach 2:
- I have created a Drupal ajax(#ajax) for the submit button. when ajax getting call, that moment itself my node is getting save.
Approach 3:
- On submit, I have created a ajax callback by jquery, and created a dialog popup. when user says 'yes' to the confirm form, I am triggering the submit function in jquery. But the action attribute in form element having the current path, so my node is not getting save.
Can anyone help me!
Comments
Comment #2
saranya ashokkumar commentedComment #3
cilefen commentedHello @saranya purushothaman: Nothing can be done without a look at the code.
Comment #4
cilefen commentedComment #5
saranya ashokkumar commentedHi cilefen,
Thanks For Your Reply!
Actually what I need is, I want to create a confirmation form for node save like delete.
Comment #6
cilefen commentedTry the documented way: https://www.drupal.org/docs/8/api/form-api/confirmformbase-to-confirm-an...
Comment #7
saranya ashokkumar commentedI have tried that. For delete operation, they are declaring this class in annotation of the entity("delete" operation) or by hook_entity_type_alter().
I want the same for save. But in annotation operations of entity, there is no save operation to define my class.
Comment #8
saranya ashokkumar commentedComment #9
cilefen commentedHi. Please be aware that we do not normally work on support requests in this issue queue—there are forums and stack exchange for that. If you think you have identified a bug in Drupal core, please identify how to reproduce it. As yet you have not posted any code so there is not a way we can help except to point you to documentation.
Comment #10
qqboy commented$(SAVE_BUTTON).click(function(){
if(confirm(Drupal.t("MESSAGES?"))){
return true;
}else{
return false;
}
});
Comment #11
bhanuprakashnani commentedComment #12
bhanuprakashnani commentedPlease give me steps to follow to solve the issue. Haven't got a complete idea. Thank you.
Comment #13
rutuj commentedYou can create a webform "confirmation form" and use "rules" module to add a action before saving new node.
Action could be:- redirect to path. In our case it is "confirmation form".
Comment #14
avpadernoI am closing this support request as per comment #9. If you need support for sites you maintain/develop, or for modules you develop, ask in the forums.