public static function WebformElementHelper::getElement in Webform 8.5
Same name and namespace in other branches
- 6.x src/Utility/WebformElementHelper.php \Drupal\webform\Utility\WebformElementHelper::getElement()
Get reference to first element by name.
Parameters
array $elements: An associative array of elements.
string $name: The element's name.
Return value
array|null Reference to found element.
1 call to WebformElementHelper::getElement()
- WebformSame::alterForm in src/
Plugin/ WebformElement/ WebformSame.php - Alter an element's associated form.
File
- src/
Utility/ WebformElementHelper.php, line 610
Class
- WebformElementHelper
- Helper class webform element methods.
Namespace
Drupal\webform\UtilityCode
public static function &getElement(array &$elements, $name) {
foreach (Element::children($elements) as $element_name) {
if ($element_name === $name) {
return $elements[$element_name];
}
elseif (is_array($elements[$element_name])) {
$child_elements =& $elements[$element_name];
if ($element =& static::getElement($child_elements, $name)) {
return $element;
}
}
}
$element = NULL;
return $element;
}