form_process_fieldset

  1. drupal
    1. drupal7
Versionen
drupal7 form_process_fieldset(&$element, &$form_state)

Adds fieldsets to the specified group or adds group members to this fieldset.

Übergabeparameter

$element An associative array containing the properties and children of the fieldset.

$form_state The $form_state array for the form this fieldset belongs to.

Rückgabewert

The processed element.

Verwandte Themen

Code

includes/form.inc, line 2238

<?php
function form_process_fieldset(&$element, &$form_state) {
  $parents = implode('][', $element['#parents']);

  // Add this fieldset to a group if one is set and if it's not being
  // added to itself.
  if (isset($element['#group']) && $element['#group'] != $parents) {
    if (isset($form_state['groups'][$element['#group']]) && !empty($form_state['groups'][$element['#group']]['#group_exists'])) {
      // Trick drupal_render() into believing this has already been output.
      // The group widget will rerender this later. This only happens when the
      // group is actually defined ('#group_exists' is TRUE). This prevents
      // fieldsets from disappearing when the group they are associated to
      // does not exist.
      // If the group does not exist yet, the element's #printed value is left
      // as is. As soon as the group is processed (fieldsets are also groups;
      // see below), this element's #printed value is set to TRUE to prevent
      // rendering in the original context.
      $element['#printed'] = TRUE;
    }

    // Store a reference to this fieldset for the vertical tabs processing
    // function.
    $form_state['groups'][$element['#group']][] = &$element;
  }

  // Each fieldset can be a group itself and gets a reference to all
  // elements in its group.
  $form_state['groups'][$parents]['#group_exists'] = TRUE;
  // There might already be elements associated with this group. Since the
  // group did not exist yet at the time they were added to this group, they
  // couldn't set #printed to TRUE (see above). We now know that this group
  // does in fact exist and set #printed to TRUE to prevent rendering in the
  // original context.
  foreach (element_children($form_state['groups'][$parents]) as $key) {
    $form_state['groups'][$parents][$key]['#printed'] = TRUE;
  }
  $element['#group_members'] = &$form_state['groups'][$parents];

  // Contains form element summary functionalities.
  drupal_add_js('misc/form.js', array('weight' => JS_LIBRARY + 1));

  return $element;
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen