You are here

function webform_civicrm_form_validate in Webform CiviCRM Integration 7.2

Same name and namespace in other branches
  1. 6.2 webform_civicrm.module \webform_civicrm_form_validate()

Validation callback for webform submissions.

1 string reference to 'webform_civicrm_form_validate'
_webform_civicrm_webform_frontend_form_alter in ./webform_civicrm_forms.inc
Alter front-end of webforms: Called by hook_form_alter() when rendering a civicrm-enabled webform Add custom prefix. Display messages. Block users who should not have access. Set webform default values.

File

./webform_civicrm.module, line 397
Webform CiviCRM Integration Module: Links webform submissions to contacts in a CiviCRM database. @author Coleman Watts

Code

function webform_civicrm_form_validate($form, &$form_state) {
  module_load_include('inc', 'webform_civicrm', 'webform_civicrm_forms');
  civicrm_initialize();
  require_once 'CRM/Utils/Type.php';
  $node = $form['#node'];
  $values = _webform_client_form_submit_flatten($node, webform_civicrm_aval($form_state, 'values:submitted'));
  $submitted = webform_civicrm_enabled_fields($node, $values);
  _webform_civicrm_form_validate($form['submitted'], $form_state, $submitted);
  if (!empty($node->webform_civicrm['data']['reg_options']['validate']) && !empty($node->webform_civicrm['data']['participant']) && !empty($node->webform_civicrm['data']['participant_reg_type'])) {

    // We need data from all pages to validate events
    if (!empty($form_state['storage']['submitted']) && webform_civicrm_aval($form_state, 'storage:page_num', 1) > 1) {
      $values += $form_state['storage']['submitted'];
      $submitted = webform_civicrm_enabled_fields($node, $values);
    }
    _webform_civicrm_participant_validate($form, $form_state, $submitted);
  }
}