简体   繁体   中英

Drupal 6 - load other content without a redirect

I have created a custom module that includes a hook_submit function. Is it possible to load another page/form at this point without having to do a redirect?

The reason being within the logic of the submit function, there are variables I would like to pass through to another page, but it consists of complex data structures (objects, arrays etc) which would not be appropriate for post/get data.

Thanks

hook_submit() is the tail end of the chain of form processing. Once it has completed it's duties you have two options: redirect (either via drupal_goto() or by returning $form["#redirect']) to another page or do nothing, in which case the page you clicked the submit button on will be reloaded.

You have several options for passing data on to your redirect destination, $_SESSION and the database being the most frequently used. You also have the option of setting complex data values in the Drupal.settings object in javascript, but in this instance that doesn't buy you much if your end goal is to parse that information via PHP.

Without specific information on what your end goal is it's hard to provide specific advice, however assuming using $_SESSION or the database as a cache isn't an option for you, you might consider looking into both core FAPI and ctools' respective implementations of multi-part forms for additional guidance.

In Drupal you can determine the path where the form will be submitted. For this you can use

$form['#action'] = url("<another page>") ;

inside your form and after submit it will take you to the another page and still you will get all the post values from that form. Use $_POST['<element_name>'] for further post value retrieval.

Hope this will help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM