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.
By Dorayaki on
Hello..
How to refresh form_token or reset the form when it is failed on validation ?
I want to prevent user from refreshing the same submission.
I check on the code that the same form_token is being use when it is failed or it is success on submission.
Can I refresh the form_token when it is fail and it is success?
I check from example modules, all the forms also same, using same form_token that are hidden.
Comments
What is your end goal here?
What is your end goal here? What are you trying to prevent, and why?
My goal is I don't want user
My goal is I don't want user to submit when they are failed. I want the form to rebuild when it is failed on validation.
I'm using drupal with some credit issue.
First the user doesn't have enough credit to process, so the user failed when he submit because the validation is checkin if the user has enough credit. The user top-up and change his mind, but he accidentally press refresh and it is submitted.
I'm trying to prevent this. I tried to use $form_state['rebuild'] after form_set_error, but no luck. :(
Sorry, I don't understand
Sorry, I don't understand your issue enough to be able to help.
Ok how about
Ok how about
If I have a form then it is failed on validation...
I want the user not able to submit by "Refresh"
When the user refresh the page, user should get new form instead getting the same error.
Example form:
That is an example..
when the user input character, the user will got error from validate function. When user refresh page by pressing ctrl+r or f5, the field of the form is not blank, instead the form will re-submit again and it will shows same error message again.
I mean is there a way to clear all the fields after form_set_error ?
or is there a way when user refresh the page, previous data is not re-submit.
None that I know of. This is
None that I know of. This is the way browsers handle posted data, it's not a Drupal thing. The question is why is this an issue?