';
$output .= drupal_render($table);
$output .= $element['#description'] ? '
' . $element['#description'] . '
' : '';
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php
index e137f9a..f375ef9 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php
@@ -124,6 +124,22 @@ public function buildForm(array $form, array &$form_state, $entity_type = NULL,
// Add Ajax wrapper.
'#prefix' => '
',
'#suffix' => '
',
+ '#tabledrag' => array(
+ array(
+ 'table_id' => $table_id,
+ 'action' => 'order',
+ 'relationship' => 'sibling',
+ 'group' => 'field-weight',
+ ),
+ array(
+ 'table_id' => $table_id,
+ 'action' => 'match',
+ 'relationship' => 'parent',
+ 'group' => 'field-parent',
+ 'subgroup' => 'field-parent',
+ 'source' => 'field-name',
+ ),
+ ),
);
// Field rows.
@@ -195,24 +211,6 @@ public function buildForm(array $form, array &$form_state, $entity_type = NULL,
$form['#attached']['library'][] = array('field_ui', 'drupal.field_ui');
- // Add tabledrag behavior.
- $order_options = array(
- 'table_id' => 'field-display-overview',
- 'action' => 'order',
- 'relationship' => 'sibling',
- 'group' => 'field-weight',
- );
- $match_options = array(
- 'table_id' => 'field-display-overview',
- 'action' => 'match',
- 'relationship' => 'parent',
- 'group' => 'field-parent',
- 'subgroup' => 'field-parent',
- 'source' => 'field-name',
- );
- drupal_attach_tabledrag($form, $order_options);
- drupal_attach_tabledrag($form, $match_options);
-
return $form;
}
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php b/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php
index aad6599..272d807 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php
@@ -136,7 +136,15 @@ public function getRegionOptions() {
* This function is assigned as a #pre_render callback in
* field_ui_element_info().
*
- * @see drupal_render().
+ * @param array $element
+ * A structured array containing two sub-levels of elements. Properties
+ * used:
+ * - #tabledrag: The value is a list of $options arrays that are passed to
+ * drupal_attach_tabledrag(). The HTML ID of the table is added to each
+ * $options array.
+ *
+ * @see drupal_render()
+ * @see drupal_pre_render_table()
*/
public function tablePreRender($elements) {
$js_settings = array();
@@ -207,6 +215,16 @@ public function tablePreRender($elements) {
'data' => array('fieldUIRowsData' => $js_settings),
);
+ // If the custom #tabledrag is set and there is a HTML ID, add the table's
+ // HTML ID to the options and attach the behavior.
+ // @see drupal_pre_render_table()
+ if (!empty($elements['#tabledrag']) && isset($elements['#attributes']['id'])) {
+ foreach ($elements['#tabledrag'] as $options) {
+ $options['table_id'] = $elements['#attributes']['id'];
+ drupal_attach_tabledrag($elements, $options);
+ }
+ }
+
return $elements;
}
diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc
index 73c9dc7..dee5b4e 100644
--- a/core/modules/file/file.field.inc
+++ b/core/modules/file/file.field.inc
@@ -413,24 +413,22 @@ function theme_file_widget_multiple($variables) {
);
}
-
$build = array(
- '#theme' => 'table',
+ '#type' => 'table',
'#header' => $headers,
'#rows' => $rows,
'#attributes' => array(
'id' => $table_id,
),
+ '#tabledrag' => array(
+ array(
+ 'action' => 'order',
+ 'relationship' => 'sibling',
+ 'group' => $weight_class,
+ ),
+ ),
);
- $options = array(
- 'table_id' => $table_id,
- 'action' => 'order',
- 'relationship' => 'sibling',
- 'group' => $weight_class,
- );
- drupal_attach_tabledrag($build, $options);
-
$output = empty($rows) ? '' : drupal_render($build);
$output .= drupal_render_children($element);
return $output;
diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc
index d3246f6..1d13ba8 100644
--- a/core/modules/image/image.admin.inc
+++ b/core/modules/image/image.admin.inc
@@ -58,14 +58,14 @@ function theme_image_style_effects($variables) {
'#header' => $header,
'#rows' => $rows,
'#attributes' => array('id' => 'image-style-effects'),
+ '#tabledrag' => array(
+ array(
+ 'action' => 'order',
+ 'relationship' => 'sibling',
+ 'group' => 'image-effect-order-weight',
+ ),
+ ),
);
- $options = array(
- 'table_id' => 'image-style-effects',
- 'action' => 'order',
- 'relationship' => 'sibling',
- 'group' => 'image-effect-order-weight',
- );
- drupal_attach_tabledrag($table, $options);
return drupal_render($table);
}
diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc
index 97ed1c2..f02d7bd 100644
--- a/core/modules/language/language.admin.inc
+++ b/core/modules/language/language.admin.inc
@@ -214,18 +214,18 @@ function theme_language_negotiation_configure_form($variables) {
}
$build = array(
- '#theme' => 'table',
+ '#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => array('id' => "language-negotiation-methods-$type"),
+ '#tabledrag' => array(
+ array(
+ 'action' => 'order',
+ 'relationship' => 'sibling',
+ 'group' => "language-method-weight-$type",
+ ),
+ ),
);
- $options = array(
- 'table_id' => "language-negotiation-methods-$type",
- 'action' => 'order',
- 'relationship' => 'sibling',
- 'group' => "language-method-weight-$type",
- );
- drupal_attach_tabledrag($build, $options);
$table = drupal_render($form[$type]['configurable']);
$table .= drupal_render($build);
diff --git a/core/modules/menu/menu.admin.inc b/core/modules/menu/menu.admin.inc
index d34f71e..57bba6d 100644
--- a/core/modules/menu/menu.admin.inc
+++ b/core/modules/menu/menu.admin.inc
@@ -59,31 +59,29 @@ function theme_menu_overview_form($variables) {
}
$table = array(
- '#theme' => 'table',
+ '#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => array(
'id' => 'menu-overview',
),
+ '#tabledrag' => array(
+ array(
+ 'action' => 'match',
+ 'relationship' => 'parent',
+ 'group' => 'menu-plid',
+ 'subgroup' => 'menu-plid',
+ 'source' => 'menu-mlid',
+ 'hidden' => TRUE,
+ 'limit' => MENU_MAX_DEPTH - 1,
+ ),
+ array(
+ 'action' => 'order',
+ 'relationship' => 'sibling',
+ 'group' => 'menu-weight',
+ ),
+ ),
);
- $match_options = array(
- 'table_id' => 'book-outline',
- 'action' => 'match',
- 'relationship' => 'parent',
- 'group' => 'menu-plid',
- 'subgroup' => 'menu-plid',
- 'source' => 'menu-mlid',
- 'hidden' => TRUE,
- 'limit' => MENU_MAX_DEPTH - 1,
- );
- $order_options = array(
- 'table_id' => 'book-outline',
- 'action' => 'order',
- 'relationship' => 'sibling',
- 'group' => 'menu-weight',
- );
- drupal_attach_tabledrag($table, $match_options);
- drupal_attach_tabledrag($table, $order_options);
$output .= drupal_render($form['inline_actions']);
$output .= drupal_render($table);
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index c0b0f02..6ebe406 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -586,10 +586,10 @@ function system_element_info() {
'#process' => array('form_process_table'),
'#element_validate' => array('form_validate_table'),
// Properties for tabledrag support.
- // The value is a list of arrays that are passed to drupal_add_tabledrag().
- // drupal_pre_render_table() prepends the HTML ID of the table to each set
- // of arguments.
- // @see drupal_add_tabledrag()
+ // The value is a list of arrays that are passed to
+ // drupal_attach_tabledrag(). drupal_pre_render_table() prepends the HTML ID
+ // of the table to each set of options.
+ // @see drupal_attach_tabledrag()
'#tabledrag' => array(),
// Render properties.
'#pre_render' => array('drupal_pre_render_table'),