protected function BulkEditFormTrait::findFormElement in Views Bulk Edit 8.2
Finds the deepest most form element and returns it.
Parameters
array $form: The form element we're searching.
string $title: The most recent non-empty title from previous form elements.
Return value
array|null The deepest most element if we can find it.
1 call to BulkEditFormTrait::findFormElement()
- BulkEditFormTrait::getSelectorForm in src/
Form/ BulkEditFormTrait.php - Builds the selector form.
File
- src/
Form/ BulkEditFormTrait.php, line 324
Class
- BulkEditFormTrait
- Common methods for Views Bulk Edit forms.
Namespace
Drupal\views_bulk_edit\FormCode
protected function &findFormElement(array &$form, $title = NULL) {
$element = NULL;
foreach (Element::children($form) as $key) {
// Not all levels have both #title and #type.
// Attempt to inherit #title from previous iterations.
// Some #titles are empty strings. Ignore them.
if (!empty($form[$key]['#title'])) {
$title = $form[$key]['#title'];
}
elseif (!empty($form[$key]['title']['#value']) && !empty($form[$key]['title']['#type']) && $form[$key]['title']['#type'] === 'html_tag') {
$title = $form[$key]['title']['#value'];
}
if (isset($form[$key]['#type']) && !empty($title)) {
// Fix empty or missing #title in $form.
if (empty($form[$key]['#title'])) {
$form[$key]['#title'] = $title;
}
$element =& $form[$key];
break;
}
elseif (is_array($form[$key])) {
$element =& $this
->findFormElement($form[$key], $title);
}
}
return $element;
}