protected static function RegistrantsElementUtility::findElementWithProperties in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/RegistrantsElementUtility.php \Drupal\rng\RegistrantsElementUtility::findElementWithProperties()
- 3.x src/RegistrantsElementUtility.php \Drupal\rng\RegistrantsElementUtility::findElementWithProperties()
Traverses the triggering element tree until an element is found.
Traverses parents tree from the triggering element to find the element with the passed in properties.
Parameters
array $form: The complete form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
array $element_properties: Traverse up until finding an element with the properties with these keys and values.
Return value
array|NULL The requested element, or NULL if the element is not found.
1 call to RegistrantsElementUtility::findElementWithProperties()
- RegistrantsElementUtility::findElement in src/
RegistrantsElementUtility.php - Traverses the triggering element tree until this element is found.
File
- src/
RegistrantsElementUtility.php, line 67
Class
Namespace
Drupal\rngCode
protected static function findElementWithProperties(array $form, FormStateInterface $form_state, array $element_properties) {
$trigger = $form_state
->getTriggeringElement();
$parents = $trigger['#parents'];
// In case $form is the element itself.
$element = $form;
while (!isset($element) || array_diff_assoc($element_properties, $element)) {
$element = NestedArray::getValue($form, $parents);
if (array_pop($parents) === NULL) {
return NULL;
}
}
return $element;
}