Remember to bookmark this article, which is often used to jump or reload form forms when you make Drupal 7 custom module.
A summary of three main points:
1. After the page is submitted, after #submit processing, you need to redirect jump to another page.
When the destination parameter is present in the 2.url path, the page jumps directly to the URL that destination refers to and cannot control the problem.
How a 3.form form implements multiple steps forms multiple steps, or after a form is submitted, how to get the value to submit on the form.
One, form form redirect (jump) to another page
The value of $form _state[' redirect ') can be a string or an array, and the value is generated by the URL, and a jump address is created.
Copy the Code code as follows: $form _state[' redirect '] = Array (
' Node/123 ',
Array
' Query ' = = Array (
' foo ' = ' bar ',
),
' Fragment ' = ' baz ',
}
The page will jump to Node/123?foo=bar#baz
Copy the Code code as follows: $form _state[' redirect '] = ' node/123 '
The page will jump to node/123
If you do not specify a value for $form_state[' redirect '], the default jumps to the current page. Drupal_goto (Current_path (), Array (' query ' = = Drupal_get_query_parameters ())); This is done in the API.
Second, form form destination (destination) is specified can also change the address of the jump
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 that the destination points to, causing the pages under some forms to be redirect to jump after the multiple buttons have been submitted.
So in the form of the #submit function, some operations can be directly deleted destination.
Copy the code as follows: if (isset ($_get[' destination ')) {
$form _state[' redirect ' = Array (' Next_step_page_url ', Array (' query ' = = Drupal_get_destination ()));
unset ($_get[' destination ');
}
The way I do this is to redefine a URL and continue to pass destination, but delete the destination in $_get. However, the destination will often be used to jump to this destination.
Third, form form implementation Multiple steps multiple steps, form form overload, get the value of form submission
These questions are, in essence, meant to keep the form going. Instead of refreshing the page. Simply execute the following code in the #submit function of the form form:
Copy the code as follows: if ($form _state[' values ' [' op '] = = t ("Next Step")) {
$form _state[' rebuild ') = TRUE;
$form _state[' storage ' [' users '] = $form _state[' values ' [' users '];
}
The value of $form_state[' storage ' [' users '] can be obtained in the define definition of the form.
Refer to DRUPAL7 related API functions:
Drupal_redirect_form
Drupal_goto
Drupal_get_destination
http://www.bkjia.com/PHPjc/736823.html www.bkjia.com true http://www.bkjia.com/PHPjc/736823.html techarticle Remember to bookmark this article, which is often used to jump or reload form forms when you make Drupal 7 custom module. The main summary of three points: 1. After the page is submitted, after #submit processing ...