You are here

function clientside_validation_should_validate in Clientside Validation 3.0.x

Same name and namespace in other branches
  1. 8.2 clientside_validation.module \clientside_validation_should_validate()
  2. 8 clientside_validation.module \clientside_validation_should_validate()
  3. 7.2 clientside_validation.module \clientside_validation_should_validate()
  4. 2.0.x clientside_validation.module \clientside_validation_should_validate()

Check whether or not an element should be validated.

1 call to clientside_validation_should_validate()
clientside_validation_add_validation in ./clientside_validation.module
Add clientside validation to a form element.

File

./clientside_validation.module, line 65
Hook implementations for the Clientside Validation module.

Code

function clientside_validation_should_validate($element, FormStateInterface &$form_state, $form_id) {
  $hook = 'clientside_validation_should_validate';
  $hook_args = [
    $element,
    $form_state,
    $form_id,
  ];

  /** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */
  $module_handler = \Drupal::moduleHandler();
  $implementations = $module_handler
    ->getImplementations($hook);
  foreach ($implementations as $implementation) {
    if ($module_handler
      ->invoke($implementation, $hook, $hook_args) === FALSE) {

      // Don't validate even if any one implementation returns false.
      return FALSE;
    }
  }
  return TRUE;
}