Commit a806db88 authored by Dries's avatar Dries
Browse files

- Patch #39085 by chx/angie: simplified #tree-#parent code.

parent f54cc812
......@@ -63,8 +63,7 @@ function drupal_get_form($form_id, &$form, $callback = NULL) {
variable_set('drupal_private_key', mt_rand());
}
$form['form_token'] = array('#type' => 'hidden', '#value' => md5($_SERVER['REMOTE_ADDR'] . $form['#token'] . variable_get('drupal_private_key',
'')));
$form['form_token'] = array('#type' => 'hidden', '#value' => md5($_SERVER['REMOTE_ADDR'] . $form['#token'] . variable_get('drupal_private_key', '')));
}
$form['form_id'] = array('#type' => 'hidden', '#default_value' => $form_id);
......@@ -286,20 +285,8 @@ function _form_builder($form_id, $form) {
// don't squash existing parents value
if (!isset($form[$key]['#parents'])) {
if ($form[$key]['#tree']) {
if (!$form['#tree']) {
// begin tree
$form[$key]['#parents'] = array($key);
}
else {
//continue tree
$form[$key]['#parents'] = array_merge($form['#parents'], array($key));
}
}
else {
// no tree
$form[$key]['#parents'] = array($key);
}
// Check to see if a tree of child elements is present. If so, continue down the tree if required.
$form[$key]['#parents'] = $form[$key]['#tree'] && $form['#tree'] ? array_merge($form['#parents'], array($key)) : array($key);
}
# Assign a decimal placeholder weight, to preserve original array order
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment