4.7.x form.inc element_children($element)
5.x common.inc element_children($element)
6.x common.inc element_children($element)
7.x common.inc element_children(&$elements, $sort = FALSE)

Get keys of a structured array tree element that are not properties (i.e., do not begin with '#').

37 calls to element_children()
book_admin_edit_submit in modules/book/book.admin.inc
Handle submission of the book administrative page form.
color_form_alter in modules/color/color.module
Implementation of hook_form_alter().
drupal_render in includes/common.inc
Renders HTML given a structured array tree.
filter_form_validate in modules/filter/filter.module
Validation callback for filter elements in a form.
form_builder in includes/form.inc
Walk through the structured form array, adding any required properties to each element and mapping the incoming $_POST data to the proper elements.

... See full list


includes/common.inc, line 3126
Common functions that many Drupal modules will need to reference.


function element_children($element) {
  return array_filter(array_keys((array) $element), 'element_child');


capellic’s picture

The idea in using element_children() is that I would haven't to go hunting down dead-end branches, thereby increasing performance?

mattcasey’s picture

This function comes in handy especially when looping through elements in forms. For example, a fieldset array will include array elements on the same level as string variables like #type, etc. that you don't want to affect.