protected function WebformEntityElementsValidator::getDuplicateNamesRecursive in Webform 6.x
Same name and namespace in other branches
- 8.5 src/WebformEntityElementsValidator.php \Drupal\webform\WebformEntityElementsValidator::getDuplicateNamesRecursive()
Recurse through elements and collect an associative array keyed by name and number of duplicate instances.
Parameters
array $elements: An array of elements.
array $names: An associative array keyed by name and number of duplicate instances.
1 call to WebformEntityElementsValidator::getDuplicateNamesRecursive()
- WebformEntityElementsValidator::validateDuplicateNames in src/
WebformEntityElementsValidator.php - Validate elements does not contain duplicate names.
File
- src/
WebformEntityElementsValidator.php, line 350
Class
- WebformEntityElementsValidator
- Webform elements validator.
Namespace
Drupal\webformCode
protected function getDuplicateNamesRecursive(array $elements, array &$names) {
foreach ($elements as $key => &$element) {
if (!WebformElementHelper::isElement($element, $key)) {
continue;
}
if (isset($element['#type'])) {
if (!isset($names[$key])) {
$names[$key] = 0;
}
else {
++$names[$key];
}
}
$this
->getDuplicateNamesRecursive($element, $names);
}
}