You are here

function _element_info in Drupal 5

Same name and namespace in other branches
  1. 4 includes/form.inc \_element_info()
  2. 6 includes/form.inc \_element_info()

Retrieve the default properties for the defined element type.

Related topics

2 calls to _element_info()
drupal_prepare_form in includes/form.inc
Prepares a structured form array by adding required elements, executing any hook_form_alter functions, and optionally inserting a validation token to prevent tampering.
form_builder in includes/form.inc
Adds some required properties to each form element, which are used internally in the form API. This function also automatically assigns the value property from the $edit array, provided the element doesn't already have an assigned value.

File

includes/form.inc, line 869

Code

function _element_info($type, $refresh = NULL) {
  static $cache;
  $basic_defaults = array(
    '#description' => NULL,
    '#attributes' => array(),
    '#required' => FALSE,
    '#tree' => FALSE,
    '#parents' => array(),
  );
  if (!isset($cache) || $refresh) {
    $cache = array();
    foreach (module_implements('elements') as $module) {
      $elements = module_invoke($module, 'elements');
      if (isset($elements) && is_array($elements)) {
        $cache = array_merge_recursive($cache, $elements);
      }
    }
    if (sizeof($cache)) {
      foreach ($cache as $element_type => $info) {
        $cache[$element_type] = array_merge_recursive($basic_defaults, $info);
      }
    }
  }
  return $cache[$type];
}