protected function ValidatorManager::getDefinitionsForElement in Clientside Validation 8
Same name and namespace in other branches
- 8.2 src/ValidatorManager.php \Drupal\clientside_validation\ValidatorManager::getDefinitionsForElement()
- 3.0.x src/ValidatorManager.php \Drupal\clientside_validation\ValidatorManager::getDefinitionsForElement()
- 2.0.x src/ValidatorManager.php \Drupal\clientside_validation\ValidatorManager::getDefinitionsForElement()
Get plugin definitions that apply to a form element.
Parameters
array $element: The form element to get the validators for.
\Drupal\Core\Form\FormStateInterface $form_state: The form state of the form this element belongs to.
Return value
array The plugin definitions that support this element.
1 call to ValidatorManager::getDefinitionsForElement()
- ValidatorManager::getValidators in src/
ValidatorManager.php - Get validators for a form element.
File
- src/
ValidatorManager.php, line 56
Class
- ValidatorManager
- Validator plugin manager.
Namespace
Drupal\clientside_validationCode
protected function getDefinitionsForElement(array $element, FormStateInterface $form_state) {
$validators = $this
->getDefinitions();
$element_validators = [];
foreach ($validators as $validator) {
if (isset($element['#type']) && in_array($element['#type'], $validator['supports']['types'])) {
$element_validators[$validator['id']] = $validator;
}
foreach ($validator['supports']['attributes'] as $attribute) {
if (isset($element['#' . $attribute]) || isset($element['#attributes'][$attribute])) {
$element_validators[$validator['id']] = $validator;
continue;
}
}
}
return $element_validators;
}