phpdrupal-7drupal-modulesdrupal-webformdrupal-hooks

Get the value of a field in a Webform in Drupal 7


I created a form with the "Webform" module. In this form I have one field of e-mail type. My question is: how can I get the value of this field when the user submits the form?

I guess I should use the hook_form_FORM_ID_alter?


Solution

  • Yes, you should use hook_form_FORM_ID_alter() (or hook_form_alter(), if you prefer).

    When You have $form argument from these hooks, You should set an array as value of $form['#submit'] with name of your function in which you will catch your needed values.

    Example:

    $form['#submit'] = array('node_form_function_submit');
    

    [...]

    function node_form_function_submit($form, $form_state) {
        $form_state['values']; // your submitted form values
    }