views:

42

answers:

1

Hi, I have this basic Drupal scenario and question:

I have a form which accepts some input from user, and a submit handler which should process data and show the result to user. In other words, I don't write anything in database or set e variables etc., just show some output to user. I was wondering how I can do this, because a submit handler redirects the flow to another menu item -which the form values ($form_state) are not available anymore. Redirecting form to itself is not useful, because I just receive the raw posted inputs -not processed $form_state.

How can I prevent the redirection and just show some output to user in submit handler?

Thank you.

+1  A: 

When you are building your form you want to set re-direct to false:

$form['#redirect'] = FALSE;

There is more on redirect here: http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#redirect

If I have understood your question correctly this is what you are after.

hookd
I tried to send out output by setting #redirect to false, but it didn't work as well. After reading the source of drupal, I found out that setting the value as above only redirects the the flow back to form page with fields set with user input. Still struggling with this issue.
farzan
Okay fair enough. Your best bet is to create the output in the form building function. a nice way of doing it is shown in the first comment here: http://drupal.org/node/870120. Hope this gets you going
hookd
Thank you! That worked like a charm. I used the $form_state['storage'] to send the result back to form function and displayed it there.
farzan

related questions