diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-10-07 17:31:39 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-10-07 17:31:39 +0000 |
commit | 800cdcc840ea138ca9c207cb43dcb6300995e4b3 (patch) | |
tree | e1081a241483a0d5f8c6a9645759b50e54f711e6 /includes/form.inc | |
parent | 07510f71e12a6a057989ffb86cfacc57134a406e (diff) | |
download | brdo-800cdcc840ea138ca9c207cb43dcb6300995e4b3.tar.gz brdo-800cdcc840ea138ca9c207cb43dcb6300995e4b3.tar.bz2 |
#700380 by mitchmac, Dave Reid, mfb, Ryan Palmer, justinrandell: Fix sorting in tableselect if #weight is not set.
Diffstat (limited to 'includes/form.inc')
-rw-r--r-- | includes/form.inc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/includes/form.inc b/includes/form.inc index 2610c9902..235d560b7 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -2932,12 +2932,12 @@ function theme_tableselect($variables) { $header = $element['#header']; if (!empty($element['#options'])) { // Generate a table row for each selectable item in #options. - foreach ($element['#options'] as $key => $value) { + foreach (element_children($element) as $key) { $row = array(); $row['data'] = array(); - if (isset($value['#attributes'])) { - $row += $value['#attributes']; + if (isset($element['#options'][$key]['#attributes'])) { + $row += $element['#options'][$key]['#attributes']; } // Render the checkbox / radio element. $row['data'][] = drupal_render($element[$key]); @@ -2991,8 +2991,6 @@ function form_process_tableselect($element) { $element['#default_value'] = array(); } - // Sort the options by their #weight if they have a #weight. - uasort($element['#options'], 'element_sort'); // Create a checkbox or radio for each item in #options in such a way that // the value of the tableselect element behaves as if it had been of type // checkboxes or radios. @@ -3023,6 +3021,9 @@ function form_process_tableselect($element) { '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL, ); } + if (isset($element['#options'][$key]['#weight'])) { + $element[$key]['#weight'] = $element['#options'][$key]['#weight']; + } } } } |