Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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 CreditAttribution: saranya ashokkumar at UniMity Solutions Pvt Limited commentedComment #3
cilefen CreditAttribution: cilefen as a volunteer commentedHello @saranya purushothaman: Nothing can be done without a look at the code.
Comment #4
cilefen CreditAttribution: cilefen as a volunteer commentedComment #5
saranya ashokkumar CreditAttribution: saranya ashokkumar at UniMity Solutions Pvt Limited 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 CreditAttribution: cilefen as a volunteer commentedTry the documented way: https://www.drupal.org/docs/8/api/form-api/confirmformbase-to-confirm-an...
Comment #7
saranya ashokkumar CreditAttribution: saranya ashokkumar at UniMity Solutions Pvt Limited 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 CreditAttribution: saranya ashokkumar at UniMity Solutions Pvt Limited commentedComment #9
cilefen CreditAttribution: cilefen as a volunteer 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 CreditAttribution: qqboy commented$(SAVE_BUTTON).click(function(){
if(confirm(Drupal.t("MESSAGES?"))){
return true;
}else{
return false;
}
});
Comment #11
bhanuprakashnani CreditAttribution: bhanuprakashnani at Google Summer of Code commentedComment #12
bhanuprakashnani CreditAttribution: bhanuprakashnani at Google Summer of Code commentedPlease give me steps to follow to solve the issue. Haven't got a complete idea. Thank you.
Comment #13
Rutuj CreditAttribution: Rutuj at Faichi Solutions Pvt Ltd for Faichi Solutions Pvt Ltd 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
apadernoI 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.