You are here

function filefield_sources_field_validate in FileField Sources 8

Same name and namespace in other branches
  1. 6 filefield_sources.module \filefield_sources_field_validate()
  2. 7 filefield_sources.module \filefield_sources_field_validate()

An #element_validate function to run source validations.

1 string reference to 'filefield_sources_field_validate'
filefield_sources_element_info_alter in ./filefield_sources.module
Implements hook_element_info_alter().

File

./filefield_sources.module, line 271
Extend FileField to allow files from multiple sources.

Code

function filefield_sources_field_validate(&$element, FormStateInterface $form_state, &$complete_form) {

  // Do all processing as needed by each source.
  $sources = filefield_sources_info();
  foreach ($sources as $source) {
    if (!isset($source['class'])) {
      continue;
    }
    $callback = [
      $source['class'],
      'validate',
    ];
    if (is_callable($callback)) {
      call_user_func_array($callback, [
        $element,
        $form_state,
        $complete_form,
      ]);
    }
  }
}