It'd be nice if other modules could use a hook to validate or process a submitted form. i.e. hook_webform_validate($form, $form_state) and hook_webform_process($form, $form_state) maybe. I'm using webform module a lot and it'd be nice if I could validate forms in my own module instead of having to cut and paste a validation function php snippet (even if its a call to one in my own module) from one form to the next.

CommentFileSizeAuthor
#1 webform_hooks.diff1000 bytesomerida
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

omerida’s picture

FileSize
1000 bytes

Attached is a patch that creates 2 hooks:
hook_webform_validate($form, $form_state) and hook_webform_submit($form, &$form_state)

quicksketch’s picture

These hooks are unnecessary, since you can already add additional validate and submit handlers using hook_form_alter().

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'webform_client_form') {
    $form['#validate'][] = 'mymodule_webform_validate';
    $form['#submit'][] = 'mymodule_webform_submit';
  }
}

function mymodule_webform_validate(&$form, &$form_state) {
  // Validate here.
}

omerida’s picture

thanks - i didn't realize you could have multiple validate and submit handlers for one form

quicksketch’s picture

Title: provide _validate and _process hooks » Provide _validate and _process hooks
Status: Active » Closed (works as designed)