By I am learning on
Hi,
A form collects input from the user e.g. budget, interest etc.
Then its submit
function custom_submit($form, &$form_state) {
uses the submitted values to retrieve the values from the database table. Now how do I display the collected info? In general PHP application the page displays the info (to which form is submitted using ACTION).
But using drupal API we simply write validate and submit handlers. So here I'm stuck :-)
Please guide,
Regards
Comments
The submit handler simply
The submit handler simply performs a procedure, usually saving data captured from the form input. After the form submits, the form/page is either reloaded or the submit handler redirects to another url. You can display the saved data on that same form if you'd like or display it on another page that the user is redirected to.
Either option you choose requires a query the db for the values you just saved and return the data in html format.
Sorry my reply is so vague. If you were more specific in your question you would get a more specific answer. =)
Lead Developer and Founder of StreamRiot.com
exactly, or the submit
exactly,
or the submit handler redirects to another url.
That's what my confusion is and so far I've been doing the same, but the problem is that I've to send either retrieved information or the form values (that I got as POST) as query string parameter.
is it the correct approach? I feel a little uneasy with this, I feel I'm doing it in a wrong manner.
Please look at the source code
Hi,
Please take a look at the source listing includes/form.inc .
Good luck. Remember it's your responsibility to research an issue before submitting to this forum ( see http://drupal.org/forum-posting ).
Also please rename the subject line of your original post so that it reflects the actual subject. How about "Redirecting a form submission with parameters". Once you have solved the issue, please go back your original post subject line and prefit it with [SOLVED] (forum guidelines http://drupal.org/forum-posting )
You have already asked about how to "How to display values after form post" here http://drupal.org/node/939158. Therefore, please be considerate of other folks in the community and rename your post so that it reflects the actual issue ("Redirecting a form submission with parameters") :)
I look forward to your corrected subject line and the results of your research :)
Thanks Jason, I'll check as
Thanks Jason, I'll check as suggested by you, I'll also rename the subject line. I apologize for the duplicate post, I didn't get a solution on my earlier post so I thought it was ambiguous (I don't how successful I was this time but I got two responses including yours).
Regards
Similar issue, totally confused
Hello,
I have a similar issue and tried to trace the source code as per the steps described above, but still don't understand what the form api is doing. Here's the scenario:
After submitting a form, I want my users to be redirected if a checkbox is checked. That's it. So far my checkbox displays fine (using hook_form_alter() ) & my custom submit function is being called. Here's my function's code:
Following the advice above:
1) I found that $form_state['redirect'] is used by drupal_redirect_form
2) ok, function a is drupal_redirect_form
3) ok, definition and source for function a found: http://api.drupal.org/api/drupal/includes--form.inc/function/drupal_redi...
so great, I need to get my value into the second parameter, which is "An optional value containing the destination path to redirect to if none is specified by the form."
4) not sure what this means exactly 'find which API method is using'... as in it uses drupal_goto? that's the actual redirection if I understand correctly, but what I need to do is just make sure it get's the path I want as a parameter - which the code above is not accomplishing...
5) have been through the following api pages:
http://api.drupal.org/api/drupal/includes--form.inc/function/drupal_proc...
http://api.drupal.org/api/drupal/includes--form.inc/function/drupal_redi...
http://api.drupal.org/api/drupal/includes--form.inc/function/form_execut...
Some more clues:
- I added a watchdog to form_execute_handlers() to see what functions were called and got (in order of execution) : node_form_validate, node_form_submit, menu_node_form_submit, my_custom_function
- I also add a watchdog to see what parameters are going to drupal_redirect_form() and saw that it was being called with $form_state['redirect'] = 'node/222'
Any ideas why my $form_state['redirect'] statement doesn't work? Been through the api documentation up and down and also through Pro Drupal Development 2nd edition, which says in the section 'Redirecting the User':
I am totally confused. Sorry for all the rambling, but just trying to make it clear what the behavior I'm seeing is like. Could anybody help?
- - turpana.com - -
Start a new thread
Hi,
Happy to help. The context of this original post is going to confuse everyone. Therefore can you please post your question in a new post.
I am going to guess that you are trying to perform a typical task. After a user submits a form you want Drupal to respond with a custom message (e.g. Thank you for submitting the form").
Please specify which version of Drupal you are using (e.g. Drupal 6 or Drupal 7). Sounds like you are modifying a an existing form? If that's right, could you please title your new post something like "Add a custom reply to an existing form".
To create the custom response you need to do perform several tasks:
I am also guessing that you are new to programming with the Drupal API. Sorry if I am wrong. Basically you want to refer to a number of items:
Again, if you please start a new trail (new post), with a definitive subject line, I will be happy to elaborate further.
Hope that helps.
Jason
Thanks so much for looking
Thanks so much for looking in. In reply to your message I've created a new thread:
http://drupal.org/node/1042908
I am using Drupal 6. Also, with respect to the first set of points you list:
As I mentioned above, I looked up and down the following api pages and the source code therein:
http://api.drupal.org/api/drupal/includes--form.inc/function/drupal_proc...
http://api.drupal.org/api/drupal/includes--form.inc/function/drupal_redi...
http://api.drupal.org/api/drupal/includes--form.inc/function/form_execut...
Also, I am using the watchdog() function to log the parameters that are being passed around, as detailed above.
If you have any advice, would be much appreciated.
- - turpana.com - -
I don't if there is a better
I don't if there is a better way but what workaround I used is that I build the query using the parameters (values) posted by the form and stored this query into a session variable before redirecting.
This has solved my problem but I'll implement and share if I get a proper solution.
Thanks