2

Using Drupal 7 and a custom form generated with the Webform module, I'm trying to get info from the submitted form to save in additional SQL tables.

I know my submit handler is being called because putting dpm('This is great news, our submit handler is being called!'); inside the submit handler gives the expected output. So does dpm($myvariable); (after setting a value for $myvariable).

But dpm($form); not only doesn't return anything, but also seems to preven the other dpm() functions from working. There are no errors logged, and the page loads otherwise normally.

I should also mention that if I put the dpm($form) in the hook_form_alter() function instead of the submit handler, it does show up, but all values appear to be default or empty, after the form is submitted.

1

Please check your submit handler signatures once ... Ideally submit function should be something like below... You can try using drupal set message for same like code given below !

function form_example_tutorial_7_submit($form, &$form_state) {
  drupal_set_message("I am inside submit handler. Printed form values below");
  drupal_set_message("<pre>" . print_r($form_state['values'], 1) . "</pre>");
  // $form_state['values'] is used to extract submitted values !
  drupal_set_message("Printing Form Structure Below !");
  drupal_set_message("<pre>" . print_r($form, 1) . "</pre>");
}
  • $form_state['values'] was indeed what I needed. I'm still perplexed as to why $form displays nothing though? – beth Oct 12 '12 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.