You are here

function webform_validation_webform_validator_alter in Webform Validation 7

Same name and namespace in other branches
  1. 6 webform_validation.module \webform_validation_webform_validator_alter()

Implements hook_webform_validator_alter().

File

./webform_validation.module, line 577

Code

function webform_validation_webform_validator_alter(&$validators) {

  // Add support for the Select (or Other) module.
  if (module_exists('select_or_other')) {

    // If this module exists, all select components can now except user input.
    // Thus we provide those components the same rules as a textfield.
    if ($validators) {
      foreach ($validators as $validator_name => $validator_info) {
        if (in_array('textfield', $validator_info['component_types'])) {
          $validators[$validator_name]['component_types'][] = 'select';
        }
        $validators[$validator_name]['component_types'] = array_unique($validators[$validator_name]['component_types']);
      }
    }
  }
}