Key points and examples of two times development of Drupal7 form form

Source: Internet
Author: User
Tags define definition

  This article mainly introduces the Drupal7 form form two development points and examples, solve the frequently used form form submission after the jump problem, the need for friends can refer to the following

Please remember to bookmark this article, which is often used to jump or overload form forms when you perform Drupal 7 custom module.   Summary three main points:   1. After the page is submitted, after #submit processing, you need redirect to jump to another page. When there is a destination parameter in the 2.url path, the page jumps directly to the URL that destination refers to and cannot control the problem. 3.form forms How to implement multiple steps forms multiple steps, or after a form is submitted, how to get the value submitted in the form.   A, form form redirect (jump) to another page   $form _state[' redirect ' value can be a string or an array, the value of the URL after the generated jump address.     Code as follows: $form _state[' redirect '] = Array (  ' node/123 ',   array (    ' query ' => array (&nb Sp     ' foo ' => ' Bar ',     ',     ' fragment ' => ' Baz ',}//page will jump to Node/123?foo=bar#baz & nbsp   Code as follows: $form _state[' redirect '] = ' node/123 '//page will jump to node/123     If the value of $form_state[' redirect ' is not specified, The default jumps to the current page. Drupal_goto (Current_path (), Array (' Query ' => drupal_get_query_parameters ())); This is done in the API.   II, Form form destination (destination) when specified can also change the address of the jump   in the Drupal_goto function, you can see if there are destination parameters in the URL path, The page directly to destination to point to the link, resulting in some forms under the multiple buttons submitted, this should be redirect jump page is not different.   So in the form of the #submitfunction, some operations can be deleted directly from the destination.     Code as follows: if (isset ($_get[' destination '))) {  $form _state[' redirect '] = Array (' Next_step_page_url '), Array (' query ' => drupal_get_destination ()));   unset ($_get[' destination ')); The approach I took was to redefine a URL and continue passing destination, but remove the destination from the $_get. However, it is often used to destination the destination of the jump.   Form form to implement multiple steps multiple steps, form the form overload, get the value of form submission   These problems in the final analysis is a meaning, is to let the form continue to submit. Instead of refreshing the page. Simply execute the following code in the #submit function of the form form: The     code is 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 form.   Reference DRUPAL7 related API functions:   Drupal_redirect_form Drupal_goto drupal_get_destination  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.