Skip to content

Instantly share code, notes, and snippets.

@kid-icarus
Created November 21, 2012 17:38
Show Gist options
  • Save kid-icarus/4126352 to your computer and use it in GitHub Desktop.
Save kid-icarus/4126352 to your computer and use it in GitHub Desktop.
recursive slam dunk
/**
* Adds an #ajax property recursively to all elements of a form.
*
* @param array $element
* The first element to recursively apply #ajax to.
*/
function recursive_ajax(&$element) {
if (element_children($element)) {
foreach (element_children($element) as $child) {
recursive_ajax($element[$child]);
}
$element['#ajax'] = array(
'wrapper' => 'stuff',
'callback' => 'stuff again',
'method' => 'replace',
);
}
else {
$element['#ajax'] = array(
'wrapper' => 'stuff',
'callback' => 'stuff again',
'method' => 'replace',
);
}
}
@sanguis
Copy link

sanguis commented Nov 21, 2012

what a simply beautiful dance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment