Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the key points of the secondary development of Drupal7 form forms?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains the "what are the main points of the secondary development of Drupal7 form forms". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what are the key points of the secondary development of Drupal7 form forms.

Three main points are summarized:

1. After the page is submitted and processed by # submit, the redirect needs to jump to another page.

When there is a destination parameter in the 2.url path, the page jumps directly to the url referred to by destination, which is out of control.

How to implement multiple steps forms multiple steps in a 3.form form, or how to get the submitted value after the form is submitted.

1. Form form redirect (jump) to another page

The value of $form_state ['redirect'] can be a string or an array, and after the value passes through url, a jump address is generated.

The copy code is 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

The copy code is 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'], it jumps to the current page by default. Drupal_goto (current_path (), array ('query' = > drupal_get_query_parameters (); this is done in API.

The address of the jump can also be changed when the Form form destination (destination) is specified

In the drupal_goto function, you can see that if there is a destination parameter in the url path, the page goes directly to the link pointed to by destination, resulting in different pages that should have been redirect jump after multiple buttons under some forms are submitted.

So in the # submit function of form, you can delete destination directly during some operations.

The copy code is as follows:

If (isset ($_ GET ['destination'])) {

$form_state ['redirect'] = array (' next_step_page_url', array ('query' = > drupal_get_destination ()

Unset ($_ GET ['destination'])

}

My approach is to redefine a url and continue to pass the destination, but delete the destination in $_ GET. However, the jump of destination as a destination is often used.

Third, the Form form implements multiple steps multiple steps, and the Form form is reloaded to obtain the value submitted by Form.

In the final analysis, these questions all mean the same thing, that is, to keep the form submitted. Instead of refreshing the page. Simply execute the following code in the # submit function of the form form:

The copy 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'] is available in the define definition of form.

Refer to Drupal7 related API functions:

Drupal_redirect_form

Drupal_goto

Drupal_get_destination

Thank you for your reading, these are the contents of "what are the main points of the secondary development of Drupal7 form forms?" after the study of this article, I believe you have a deeper understanding of what the main points of the secondary development of Drupal7 form forms have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report