Augustin (Beginner) wrote:
I thought I grocked the new form API, but I have just been pulling my hair trying to do something that I thought would be fairly easy. I guess I still deserve my handle 'beginner' :/ .
In the code below, I create a hook_menu() callback to the function formtest() with a form. I want to be able to print some information according to the form that has just been submitted (here, a simple text string), then reprint the form below that. I know that $_POST['op'] is set when I submit (and the process die()s when I uncomment that line), but I can't get the information submitted to be displayed above the form.
I have tried using the function formtest_submit() but returning a value there doesn't get the expected result (it seems it's a path callback).
That is exactly right. I always use this to send the user's browser to a path with all of the search terms in the URL. For example, search.module sends people to .../type/search+query. The following request will be a GET. Then a page can be served in the usual way, not needing to worry about $_POST. arg(n), hook_menu()'s callback arguments, and/or automatically passed callback arguments may be used. And the resulting page is bookmark-able. (or you can return either NULL or FALSE, I forget which, from formtest_submit() and turn off redirection and use $_POST wherever you need it) -- Neil Drumm http://delocalizedham.com/