You are here

function clientside_validation_get_validators in Clientside Validation 7.2

1 call to clientside_validation_get_validators()
clientside_validation_add_validation in ./clientside_validation.module

File

./clientside_validation.module, line 430
Add client side validation to forms.

Code

function clientside_validation_get_validators($element, &$form_state) {
  static $plugins = FALSE;
  ctools_include('plugins');
  $defaults = array(
    'validator' => array(
      'constructor argument' => array(),
    ),
  );
  if (!$plugins) {
    $plugins = ctools_get_plugins('clientside_validation', 'validator');
    foreach ($plugins as $plugin_id => $plugin) {
      $plugin = drupal_array_merge_deep($defaults, $plugin);
      $plugin['class'] = ctools_plugin_get_class($plugin, 'validator');
      $plugins[$plugin_id] = $plugin;
    }
    uasort($plugins, 'drupal_sort_weight');
  }
  $form_settings = clientside_validation_settings_current_form();
  $validators = array();
  foreach ($plugins as $plugin_id => $plugin) {
    if ($form_settings['plugins'][$plugin_id]) {
      if ($plugin['class'] && ($instance = clientside_validation_get_validator_instance($plugin['class'], $plugin['validator']['constructor argument']))) {
        if ($instance
          ->supports($element, $form_state)) {
          $validators[] = $instance;
        }
      }
    }
  }
  return $validators;
}