Skip to content

Instantly share code, notes, and snippets.

Avatar

Evan Donovan evandonovan

View GitHub Profile
@evandonovan
evandonovan / find_element()
Created May 14, 2010 — forked from wimleers/find_element()
Wim Leers' recursive code - find form elements of given type
View find_element()
<?php
function find_element($form, $element_type) {
if (isset($form['#type']) && $form['#type'] == $element_type) {
return $form;
}
else {
foreach (element_children($form) as $name) {
if (is_array($form[$name])) {
$element = find_element($form[$name], $element_type);
if ($element !== FALSE) {