diff --git a/core/modules/views/views_ui/admin.inc b/core/modules/views/views_ui/admin.inc index 53601bf..f7eedcb 100644 --- a/core/modules/views/views_ui/admin.inc +++ b/core/modules/views/views_ui/admin.inc @@ -609,12 +609,23 @@ function views_ui_rearrange_form($form, &$form_state) { } } + $form['fields'] = array( + '#type' => 'table', + '#header' => array('', t('Weight'), t('Remove')), + '#empty' => t('No fields available.'), + '#tabledrag' => array( + array('order', 'sibling', 'weight'), + ), + '#tree' => TRUE, + '#prefix' => '
', + '#suffix' => '
', + ); + foreach ($display->getOption($types[$type]['plural']) as $id => $field) { - $form['fields'][$id] = array('#tree' => TRUE); - $form['fields'][$id]['weight'] = array( - '#type' => 'textfield', - '#default_value' => ++$count, - ); + $form['fields'][$id] = array(); + + $form['fields'][$id]['#attributes'] = array('class' => array('draggable'), 'id' => 'views-row-' . $id); + $handler = $display->getHandler($type, $id); if ($handler) { $name = $handler->adminLabel() . ' ' . $handler->adminSummary(); @@ -629,30 +640,29 @@ function views_ui_rearrange_form($form, &$form_state) { else { $form['fields'][$id]['name'] = array('#markup' => t('Broken field @id', array('@id' => $id))); } + + $form['fields'][$id]['weight'] = array( + '#type' => 'textfield', + '#default_value' => ++$count, + '#attributes' => array('class' => array('weight')), + ); + $form['fields'][$id]['removed'] = array( '#type' => 'checkbox', '#id' => 'views-removed-' . $id, '#attributes' => array('class' => array('views-remove-checkbox')), '#default_value' => 0, + '#suffix' => l('' . t('Remove') . '', 'javascript:void()', array('attributes' => array('id' => 'views-remove-link-' . $id, 'class' => array('views-hidden', 'views-button-remove', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item')), 'html' => TRUE)), ); } - // Add javascript settings that will be added via $.extend for tabledragging - $form['#js']['tableDrag']['arrange']['weight'][0] = array( - 'target' => 'weight', - 'source' => NULL, - 'relationship' => 'sibling', - 'action' => 'order', - 'hidden' => TRUE, - 'limit' => 0, - ); - $name = NULL; if (isset($form_state['update_name'])) { $name = $form_state['update_name']; } $view->getStandardButtons($form, $form_state, 'views_ui_rearrange_form'); + return $form; } @@ -667,7 +677,7 @@ function views_ui_rearrange_form_submit($form, &$form_state) { $new_fields = $order = array(); // Make an array with the weights - foreach ($form_state['values'] as $field => $info) { + foreach ($form_state['values']['fields'] as $field => $info) { // add each value that is a field with a weight to our list, but only if // it has had its 'removed' checkbox checked. if (is_array($info) && isset($info['weight']) && empty($info['removed'])) { diff --git a/core/modules/views/views_ui/views_ui.theme.inc b/core/modules/views/views_ui/views_ui.theme.inc index cb5396b..b353345 100644 --- a/core/modules/views/views_ui/views_ui.theme.inc +++ b/core/modules/views/views_ui/views_ui.theme.inc @@ -245,38 +245,6 @@ function theme_views_ui_reorder_displays_form($vars) { /** * Turn the rearrange form into a proper table */ -function theme_views_ui_rearrange_form($variables) { - $form = $variables['form']; - - $rows = array(); - foreach (element_children($form['fields']) as $id) { - if (isset($form['fields'][$id]['name'])) { - $row = array(); - $row[] = drupal_render($form['fields'][$id]['name']); - $form['fields'][$id]['weight']['#attributes']['class'] = array('weight'); - $row[] = drupal_render($form['fields'][$id]['weight']); - $row[] = drupal_render($form['fields'][$id]['removed']) . l('' . t('Remove') . '', 'javascript:void()', array('attributes' => array('id' => 'views-remove-link-' . $id, 'class' => array('views-hidden', 'views-button-remove', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item')), 'html' => TRUE)); - $rows[] = array('data' => $row, 'class' => array('draggable'), 'id' => 'views-row-' . $id); - } - } - if (empty($rows)) { - $rows[] = array(array('data' => t('No fields available.'), 'colspan' => '2')); - } - - $header = array('', t('Weight'), t('Remove')); - $output = drupal_render($form['override']); - $output .= '
'; - $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'arrange'))); - $output .= '
'; - $output .= drupal_render_children($form); - drupal_add_tabledrag('arrange', 'order', 'sibling', 'weight'); - - return $output; -} - -/** - * Turn the rearrange form into a proper table - */ function theme_views_ui_rearrange_filter_form(&$vars) { $form = $vars['form']; $rows = $ungroupable_rows = array();