element_children

  1. drupal
    1. 4.7 form.inc
    2. 5 common.inc
    3. 6
    4. 7
Versions
4.7 – 6 element_children($element)
7 element_children(&$elements, $sort = FALSE)

Return the children of an element, optionally sorted by weight.

Parameters

$elements The element to be sorted.

$sort Boolean to indicate whether the children should be sorted by weight.

Return value

The array keys of the element's children.

▾ 68 functions call element_children()

book_admin_edit_submit in drupal/modules/book/book.admin.inc
Handle submission of the book administrative page form.
dashboard_form_block_admin_configure_alter in drupal/modules/dashboard/dashboard.module
Implements hook_form_FORM_ID_alter().
dashboard_form_block_admin_display_form_alter in drupal/modules/dashboard/dashboard.module
Implements hook_form_FORM_ID_alter().
drupal_pre_render_links in drupal/includes/common.inc
#pre_render callback that collects child links into a single array.
drupal_render in drupal/includes/common.inc
Renders HTML given a structured array tree.
drupal_render_children in drupal/includes/common.inc
Render children of an element and concatenate them.
drupal_render_collect_attached in drupal/includes/common.inc
Collect #attached for an element and all child elements into a single array.
element_get_visible_children in drupal/includes/common.inc
Return the visibile children of an element.
field_ui_field_edit_instance_pre_render in drupal/modules/field_ui/field_ui.admin.inc
Pre-render function for field instance settings.
field_ui_table_pre_render in drupal/modules/field_ui/field_ui.admin.inc
Pre-render callback for field_ui_table elements.
file_field_widget_process in drupal/modules/file/file.field.inc
An element #process callback for the file_generic field type.
file_field_widget_process_multiple in drupal/modules/file/file.field.inc
An element #process callback for a group of file_generic fields.
filter_process_format in drupal/modules/filter/filter.module
Expands an element into a base element with text format selector attached.
form_builder in drupal/includes/form.inc
Walk through the structured form array, adding any required properties to each element and mapping the incoming input data to the proper elements. Also, execute any #process handlers attached to a specific element.
form_pre_render_fieldset in drupal/includes/form.inc
Adds members of this group as actual elements for rendering.
forum_overview in drupal/modules/forum/forum.admin.inc
Returns an overview list of existing forums and containers
hook_field_attach_view_alter in drupal/modules/field/field.api.php
Perform alterations on field_attach_view() or field_view_field().
image_field_widget_form in drupal/modules/image/image.field.inc
Implements hook_field_widget_form().
menu_overview_form in drupal/modules/menu/menu.admin.inc
Form for editing an entire menu tree at once.
menu_overview_form_submit in drupal/modules/menu/menu.admin.inc
Submit handler for the menu overview form.
overlay_page_alter in drupal/modules/overlay/overlay.module
Implements hook_page_alter().
profile_admin_overview_submit in drupal/modules/profile/profile.admin.inc
Submit handler to update changed profile field weights and categories.
rdf_field_attach_view_alter in drupal/modules/rdf/rdf.module
Implements hook_field_attach_view_alter().
render_example_page_alter in examples/render_example/render_example.module
Implements hook_page_alter().
system_modules in drupal/modules/system/system.admin.inc
Menu callback; provides module enable/disable interface.
system_theme_settings in drupal/modules/system/system.admin.inc
Form builder; display theme configuration for entire site and individual themes.
taxonomy_term_confirm_parents in drupal/modules/taxonomy/taxonomy.admin.inc
Form builder for the confirmation of multiple term parents.
template_preprocess_block_admin_display_form in drupal/modules/block/block.admin.inc
Processes variables for block-admin-display-form.tpl.php.
template_preprocess_book_all_books_block in drupal/modules/book/book.module
Process variables for book-all-books-block.tpl.php.
template_preprocess_comment in drupal/modules/comment/comment.module
Process variables for comment.tpl.php.
template_preprocess_node in drupal/modules/node/node.module
Process variables for node.tpl.php
template_preprocess_search_block_form in drupal/modules/search/search.module
Process variables for search-block-form.tpl.php.
template_preprocess_taxonomy_term in drupal/modules/taxonomy/taxonomy.module
Process variables for taxonomy-term.tpl.php.
template_preprocess_user_profile in drupal/modules/user/user.pages.inc
Process variables for user-profile.tpl.php.
theme_aggregator_categorize_items in drupal/modules/aggregator/aggregator.pages.inc
Returns HTML for the aggregator page list form for assigning categories.
theme_book_admin_table in drupal/modules/book/book.admin.inc
Returns HTML for a book administration form.
theme_color_scheme_form in drupal/modules/color/color.module
Returns HTML for a theme's color form.
theme_exposed_filters in drupal/modules/system/system.module
Returns HTML for an exposed filter form.
theme_field_multiple_value_form in drupal/modules/field/field.form.inc
Returns HTML for an individual form element.
theme_field_ui_table in drupal/modules/field_ui/field_ui.admin.inc
Returns HTML for Field UI overview tables.
theme_file_widget_multiple in drupal/modules/file/file.field.inc
Returns HTML for a group of file upload widgets.
theme_filter_admin_format_filter_order in drupal/modules/filter/filter.admin.inc
Returns HTML for a text format's filter order form.
theme_filter_admin_overview in drupal/modules/filter/filter.admin.inc
Returns HTML for the text format administration overview form.
theme_image_anchor in drupal/modules/image/image.admin.inc
Returns HTML for a 3x3 grid of checkboxes for image anchors.
theme_image_style_effects in drupal/modules/image/image.admin.inc
Returns HTML for a listing of the effects within a specific image style.
theme_locale_date_format_form in drupal/modules/locale/locale.admin.inc
Returns HTML for a locale date format form.
theme_menu_overview_form in drupal/modules/menu/menu.admin.inc
Returns HTML for the menu overview form into a table.
theme_node_search_admin in drupal/modules/node/node.module
Returns HTML for the content ranking part of the search settings admin page.
theme_poll_choices in drupal/modules/poll/poll.module
Returns HTML for an admin poll form for choices.
theme_profile_admin_overview in drupal/modules/profile/profile.admin.inc
Returns HTML for the profile field overview form into a drag and drop enabled table.
theme_render_example_aggregate in examples/render_example/render_example.module
A #theme function has the responsibility of consolidating/rendering the children's markup and returning it, where it will be placed in the element's #children property.
theme_shortcut_set_customize in drupal/modules/shortcut/shortcut.admin.inc
Returns HTML for a shortcut set customization form.
theme_simpletest_test_table in drupal/modules/simpletest/simpletest.pages.inc
Returns HTML for a test list generated by simpletest_test_form() into a table.
theme_system_date_time_settings in drupal/modules/system/system.admin.inc
Returns HTML for the date settings form.
theme_system_modules_fieldset in drupal/modules/system/system.admin.inc
Returns HTML for the modules form.
theme_system_modules_uninstall in drupal/modules/system/system.admin.inc
Returns HTML for a table of currently disabled modules.
theme_tableselect in drupal/includes/form.inc
Returns HTML for a table with radio buttons or checkboxes.
theme_taxonomy_overview_terms in drupal/modules/taxonomy/taxonomy.admin.inc
Returns HTML for a terms overview form as a sortable list of terms.
theme_taxonomy_overview_vocabularies in drupal/modules/taxonomy/taxonomy.admin.inc
Returns HTML for the vocabulary overview form as a sortable list of vocabularies.
theme_user_admin_permissions in drupal/modules/user/user.admin.inc
Returns HTML for the administer permissions page.
theme_user_admin_roles in drupal/modules/user/user.admin.inc
Returns HTML for the role order and new role form.
user_admin_settings in drupal/modules/user/user.admin.inc
Form builder; Configure user settings for this site.
user_cancel_confirm_form in drupal/modules/user/user.pages.inc
Form builder; confirm form for cancelling user account.
user_multiple_cancel_confirm in drupal/modules/user/user.module
_authorize_filetransfer_connection_settings_set_defaults in drupal/includes/authorize.inc
Recursively fill in the default settings on a file transfer connection form.
_color_theme_select_form_alter in drupal/modules/color/color.module
Helper for hook_form_FORM_ID_alter() implementations.
_form_validate in drupal/includes/form.inc
Performs validation on form elements. First ensures required fields are completed, #maxlength is not exceeded, and selected options were in the list of options given to the user. Then calls user-defined validators.
_simpletest_batch_operation in drupal/modules/simpletest/simpletest.module
Batch operation callback.

Code

drupal/includes/common.inc, line 6110

<?php
function element_children(&$elements, $sort = FALSE) {
  // Do not attempt to sort elements which have already been sorted.
  $sort = isset($elements['#sorted']) ? !$elements['#sorted'] : $sort;

  // Filter out properties from the element, leaving only children.
  $children = array();
  $sortable = FALSE;
  foreach ($elements as $key => $value) {
    if ($key === '' || $key[0] !== '#') {
      $children[$key] = $value;
      if (is_array($value) && isset($value['#weight'])) {
        $sortable = TRUE;
      }
    }
  }
  // Sort the children if necessary.
  if ($sort && $sortable) {
    uasort($children, 'element_sort');
    // Put the sorted children back into $elements in the correct order, to
    // preserve sorting if the same element is passed through
    // element_children() twice.
    foreach ($children as $key => $child) {
      unset($elements[$key]);
      $elements[$key] = $child;
    }
    $elements['#sorted'] = TRUE;
  }

  return array_keys($children);
}
?>