You are here

function webform_client_form_validate in Webform 6.2

Same name and namespace in other branches
  1. 5.2 webform.module \webform_client_form_validate()
  2. 5 webform.module \webform_client_form_validate()
  3. 6.3 webform.module \webform_client_form_validate()
  4. 7.4 webform.module \webform_client_form_validate()
  5. 7.3 webform.module \webform_client_form_validate()
1 string reference to 'webform_client_form_validate'
webform_client_form in ./webform.module
Client form generation function. If this is displaying an existing submission, pass in the $submission variable with the contents of the submission to be displayed.

File

./webform.module, line 1668

Code

function webform_client_form_validate($form, $form_state) {
  $node = node_load($form_state['values']['details']['nid']);
  $sid = $form_state['values']['details']['sid'];

  // Check that the user has not exceeded the submission limit.
  // This usually will only apply to anonymous users when the page cache is
  // enabled, because they may submit the form even if they do not have access.
  if ($node->webform['submit_limit'] != -1) {

    // -1: Submissions are never throttled.
    module_load_include('inc', 'webform', 'webform_submissions');
    if (empty($sid) && ($limit_exceeded = _webform_submission_limit_check($node))) {
      $error = theme('webform_view_messages', $node, 0, 1, 0, $limit_exceeded, array_keys(user_roles()));
      form_set_error('', $error);
      return;
    }
  }

  // Flatten trees within the submission.
  $form_state['values']['submitted_tree'] = $form_state['values']['submitted'];
  $form_state['values']['submitted'] = _webform_client_form_submit_flatten($node, $form_state['values']['submitted']);
  if (trim($node->webform['additional_validate'])) {

    // Support for Drupal 5 validation code.
    $form_values =& $form_state['values'];

    // We use eval here (rather than drupal_eval) because the user needs access to local variables.
    eval('?>' . $node->webform['additional_validate']);
  }
}