Home >Backend Development >PHP Tutorial >Key points and examples of secondary development of Drupal7 form_PHP tutorial
Please remember to bookmark this article. When you develop Drupal 7 custom module, you will often use form jumps or reloads.
Mainly summarize three key points:
1. After the page is submitted, after #submit processing, you need to redirect to another page.
2. When there is a destination parameter in the url path, the page jumps directly to the url pointed by the destination, which is an uncontrollable problem.
3. How to implement multiple steps forms, or how to get the submitted value in the form after the form is submitted.
1. Form redirect (jump) to another page
The value of $form_state['redirect'] can be a string or an array. After the value passes through the url, a jump address is generated.
If the value of $form_state['redirect'] is not specified, it will jump to the current page by default. drupal_goto(current_path(), array('query' => drupal_get_query_parameters())); This is how it is executed in the API.
2. When the Form form destination is specified, the jump address can also be changed
In the drupal_goto function, you can see that if there is a destination parameter in the url path, the page will go directly to the link pointed to by the destination. As a result, after multiple buttons under some forms are submitted, the page that should be redirected will also redirect. Not quite the same.
So in the #submit function of the form, the destination can be deleted directly during certain operations.
3. Form implements multiple steps, reloads the Form, and obtains the value submitted by the Form
These questions all have the same meaning in the final analysis, which is to allow the form to continue to be submitted. instead of refreshing the page. Just execute the following code in the #submit function of the form:
Refer to Drupal7 related API functions:
drupal_redirect_form
drupal_goto
drupal_get_destination