element_children

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.

▾ 60 functions call element_children()

book_admin_edit_submit in modules/book/book.admin.inc
Handle submission of the book administrative page form.
drupal_render in includes/common.inc
Renders HTML given a structured array tree.
drupal_render_children in includes/common.inc
Render children of an element and concatenate them.
field_ui_field_edit_instance_pre_render in modules/field_ui/field_ui.admin.inc
Pre-render function for field instance settings.
file_field_widget_process in modules/file/file.field.inc
An element #process callback for the file_generic field type.
file_field_widget_process_multiple in modules/file/file.field.inc
An element #process callback for a group of file_generic fields.
form_builder in 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 includes/form.inc
Adds members of this group as actual elements for rendering.
form_process_fieldset in includes/form.inc
Adds fieldsets to the specified group or adds group members to this fieldset.
forum_overview in modules/forum/forum.admin.inc
Returns an overview list of existing forums and containers
image_field_widget in modules/image/image.field.inc
Implementation of hook_field_widget().
profile_admin_overview_submit in modules/profile/profile.admin.inc
Submit handler to update changed profile field weights and categories.
system_modules in modules/system/system.admin.inc
Menu callback; provides module enable/disable interface.
system_theme_settings in modules/system/system.admin.inc
Form builder; display theme configuration for entire site and individual themes.
taxonomy_term_confirm_parents in modules/taxonomy/taxonomy.admin.inc
Form builder for the confirmation of multiple term parents.
template_preprocess_block_admin_display_form in modules/block/block.admin.inc
Process variables for block-admin-display.tpl.php.
template_preprocess_book_all_books_block in modules/book/book.module
Process variables for book-all-books-block.tpl.php.
template_preprocess_comment in modules/comment/comment.module
Process variables for comment.tpl.php.
template_preprocess_field_ui_display_overview_form in modules/field_ui/field_ui.admin.inc
Theme preprocess function for field_ui-display-overview-form.tpl.php.
template_preprocess_field_ui_field_overview_form in modules/field_ui/field_ui.admin.inc
Theme preprocess function for field_ui-field-overview-form.tpl.php.
template_preprocess_node in modules/node/node.module
Process variables for node.tpl.php
template_preprocess_search_block_form in modules/search/search.module
Process variables for search-block-form.tpl.php.
template_preprocess_user_profile in modules/user/user.pages.inc
Process variables for user-profile.tpl.php.
theme_aggregator_categorize_items in modules/aggregator/aggregator.pages.inc
Theme the page list form for assigning categories.
theme_book_admin_table in modules/book/book.admin.inc
Theme function for the book administration page form.
theme_dblog_filters in modules/dblog/dblog.module
Theme dblog administration filter selector.
theme_field_formatter_field_test_multiple in modules/simpletest/tests/field_test.module
Theme function for 'field_test_multiple' formatter.
theme_field_formatter_file_table in modules/file/file.field.inc
Theme function for the 'table' formatter.
theme_field_formatter_FORMATTER_MULTIPLE in modules/field/field.api.php
Theme function for a field formatter.
theme_field_multiple_value_form in modules/field/field.form.inc
Theme an individual form element.
theme_file_widget_multiple in modules/file/file.field.inc
Theme a group of file upload widgets.
theme_filter_admin_order in modules/filter/filter.admin.inc
Theme filter order configuration form.
theme_filter_admin_overview in modules/filter/filter.admin.inc
Theme the text format administration overview form.
theme_image_anchor in modules/image/image.admin.inc
Theme callback for displaying a grid of checkboxes.
theme_image_style_effects in modules/image/image.admin.inc
Theme callback for listing the effects within a specific image style.
theme_locale_date_format_form in modules/locale/locale.module
Theme locale date format form.
theme_locale_translation_filters in modules/locale/locale.module
Theme locale translation filter selector.
theme_node_filters in modules/node/node.admin.inc
Theme node administration filter selector.
theme_node_search_admin in modules/node/node.module
Theme the content ranking part of the search settings admin page.
theme_poll_choices in modules/poll/poll.module
Theme the admin poll form for choices.
theme_profile_admin_overview in modules/profile/profile.admin.inc
Theme the profile field overview into a drag and drop enabled table.
theme_scaffolding_example_overview_form in developer/examples/scaffolding_example/scaffolding_example.admin.inc
Theme the drag-and-drop overview form.
theme_shortcut_set_customize in modules/shortcut/shortcut.admin.inc
Theme function for the shortcut set customization form.
theme_simpletest_test_table in modules/simpletest/simpletest.pages.inc
Theme the test list generated by simpletest_test_form() into a table.
theme_system_date_time_settings in modules/system/system.admin.inc
Theme function for date settings form.
theme_system_modules_fieldset in modules/system/system.admin.inc
Theme callback for the modules form.
theme_system_modules_uninstall in modules/system/system.admin.inc
Themes a table of currently disabled modules.
theme_system_themes_form in modules/system/system.admin.inc
Theme function for the system themes form.
theme_taxonomy_overview_terms in modules/taxonomy/taxonomy.admin.inc
Theme the terms overview as a sortable list of terms.
theme_taxonomy_overview_vocabularies in modules/taxonomy/taxonomy.admin.inc
Theme the vocabulary overview as a sortable list of vocabularies.
theme_upload_form_current in modules/upload/upload.module
Theme the attachments list.
theme_user_admin_permissions in modules/user/user.admin.inc
Theme the administer permissions page.
theme_user_filters in modules/user/user.admin.inc
Theme user administration filter selector.
user_admin_settings in modules/user/user.admin.inc
Form builder; Configure user settings for this site.
user_cancel_confirm_form in modules/user/user.pages.inc
Form builder; confirm form for cancelling user account.
user_multiple_cancel_confirm in modules/user/user.module
user_register_form in modules/user/user.module
Form builder; the user registration form.
_form_validate in 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 modules/simpletest/simpletest.module
Batch operation callback.
_system_settings_form_automatic_defaults in modules/system/system.module

Code

includes/common.inc, line 5295

<?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[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);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.