diff --git a/core/includes/common.inc b/core/includes/common.inc index 91956d477a4..a584b4d160c 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -2800,7 +2800,7 @@ function drupal_get_library($module, $name = NULL) { } /** - * Assists in adding the tableDrag JavaScript behavior to a themed table. + * Assists in attaching the tableDrag JavaScript behavior to a themed table. * * Draggable tables should be used wherever an outline or list of sortable items * needs to be arranged by an end-user. Draggable tables are very flexible and @@ -2839,9 +2839,13 @@ function drupal_get_library($module, $name = NULL) { * - Rows with the 'tabledrag-leaf' class cannot have child rows. * - Rows with the 'tabledrag-root' class cannot be nested under a parent row. * - * Calling drupal_add_tabledrag() would then be written as such: + * Calling drupal_attach_tabledrag() would then be written as such: * @code - * drupal_add_tabledrag('my-module-table', 'order', 'sibling', 'my-elements-weight'); + * drupal_attach_tabledrag('my-module-table', array( + * 'action' => 'order', + * 'relationship' => 'sibling', + * 'group' => 'my-elements-weight', + * ); * @endcode * * In a more complex case where there are several groups in one column (such as @@ -2851,13 +2855,19 @@ function drupal_get_library($module, $name = NULL) { * $form['my_elements'][$region][$delta]['weight']['#attributes']['class'] = array('my-elements-weight', 'my-elements-weight-' . $region); * @endcode * - * $group is still 'my-element-weight', and the additional $subgroup variable - * will be passed in as 'my-elements-weight-' . $region. This also means that - * you'll need to call drupal_add_tabledrag() once for every region added. + * The 'group' option is still 'my-element-weight', and the additional + * 'subgroup' option will be passed in as 'my-elements-weight-' . $region. This + * also means that you'll need to call drupal_attach_tabledrag() once for every + * region added. * * @code * foreach ($regions as $region) { - * drupal_add_tabledrag('my-module-table', 'order', 'sibling', 'my-elements-weight', 'my-elements-weight-' . $region); + * drupal_attach_tabledrag('my-module-table', array( + * 'action' => 'order', + * 'relationship' => sibling', + * 'group' => 'my-elements-weight', + * 'subgroup' => my-elements-weight-' . $region, + * )); * } * @endcode * @@ -2867,69 +2877,71 @@ function drupal_get_library($module, $name = NULL) { * theme_menu_overview_form() for an example creating a table containing parent * relationships. * - * Note that this function should be called from the theme layer, such as in a - * .html.twig file, theme_ function, or in a template_preprocess function, not - * in a form declaration. Though the same JavaScript could be added to the page - * using drupal_add_js() directly, this function helps keep template files - * clean and readable. It also prevents tabledrag.js from being added twice - * accidentally. + * @param $element + * A form element to attach the tableDrag behavior to. + * @param array $options + * These options are used to generate JavaScript settings necessary to + * configure the tableDrag behavior appropriately for this particular table. + * An associative array containing the following keys: + * - 'table_id': String containing the target table's id attribute. + * If the table does not have an id, one will need to be set, + * such as