tags:

views:

68

answers:

1

Hello,

Im using Drupal 6.19 and the webform module on my site.On a particular form,i want to do some additional processing with the values entered,so i created a module and implemented hook_form_alter, and added my own function called mymodule_webform_submit to the list of submit event handlers.

Suppose i have two fields in the form having field key values name and address respectively. How to print the values of those fields in mymodule_webform_submit function ?. Some example would be really appreciated. Below is my code so far.

<?php
    function mymodule_form_alter(&$form, &$form_state, $form_id) {
      if($form_id == 'webform_client_form_8') {

         $form['#submit'][] = 'mymodule_webform_submit';

      }

    }

    function mymodule_webform_submit(&$form,&$form_state) {
      drupal_set_message($form_state['values']['name']);

    }


?>

Please help Thank You

A: 

You're missing the arguments to your submit function. Once those are added, your values should be in $form_state['values']. It should be something like:

function mymodule_webform_submit($form, &$form_state) {
  print $form_state['values']['name'];
  print $form_state['values']['address'];
}

But do whatever you want with the values in there. Just make sure you have the correct element keys. You could see what's available by putting var_export($form_state['values']); exit(); inside the function and submitting the form.

jonathanpglick
Thanks for the reply jon.I printed the value of a text field using drupal_set_message,but it does not show anything.Also,tried doing a print as you suggested,but its not printing the value entered by the user before submitting the form.I have edited my code above to reflect the changes made.Please help.
Joe
You could try using "var_export($form_state['values']); exit;" inside the submit function to print everything that the form submitted. This should show you the structure and what is available.
jonathanpglick