Is there an easy way to read user input from a form when generating the next display of the same form?
The world's most comment form action seems impossible in Drupal 4.7.0. All I want to do is have the values entered into a form available for input to the next display of the same form. All the examples that I can find use the values in a "submit" function that displays nothing then the values are thrown away. There must be something I am missing.
I display page A with a form and a submit button at the bottom. The user enters data then clicks submit and I end up back at the function that creates the form. I should now be able to read the user's input, set the defaults for the next display of the same form and perform actions based on the user's input.
Some of the examples in the Drupal documentation show a drupal_goto() which performs a page redirect. I have the user arriving back at the right page which means there is no need to then redirect the user to the same page.
Some examples show how to perform an action in a "submit" function but then the user's input data disappears. The only data that is retained is the data that ends up in the database. I do not need the overhead of a database write to pass data from one function to another.
There are lots of examples that display a form, validate the form but never put the data back into the next display of the same form. Some modules perform the trick successfully but the trick is not obvious from the code.
Is there an easy way to simply read the user input when generating the form?
Comments
$_SESSION shortcut
I used a shortcut array in $_SESSION. Hopefully there is a better way to pass form data within Drupal 4.7.
petermoulding.com/web_architect
petermoulding.com/web_architect
There must be another way that we're missing??
I've been banging my head on this problem for a couple of hours, so was hoping I'm missing something simple...
I submit my block form, my menu callback is fired, running my submit handler, but when it goes to display my block again it sees that $_POST['edit'] is set, so drupal_get_form does the default redirect "drupal_goto($_GET['q'])", firing my callback again, but this time with no form data.
I can stop this by setting $_POST['edit'] to NULL in my callback, but this is pretty nasty and stops other code from using the data to set form defaults.
Any help on this would be much appreciated!
Simon
Thank you Google!
Use:
$form['#redirect'] = FALSE;
as per advice at:
http://drupal.org/node/56129