summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcatch2011-11-05 02:43:04 (GMT)
committercatch2011-11-05 02:43:04 (GMT)
commitfd5d91d0ce11786cfcd15dcb8b4c407f92756213 (patch)
tree5e998a62c8bb2ec8a503b45ccecf4888473e8b45
parent4060b5cf744d7467bab94ed4efc9508968e2ede4 (diff)
Issue #589440 by Boobaa, JanZ, pwolanin, mlncn, TomiMikola, willmoy, marcp et all: Fixed Reordering fails with more than 31 book pages in a book.
-rw-r--r--core/modules/book/book.admin.inc11
-rw-r--r--core/modules/book/book.module6
2 files changed, 9 insertions, 8 deletions
diff --git a/core/modules/book/book.admin.inc b/core/modules/book/book.admin.inc
index 7b9dea3..08ec5ec 100644
--- a/core/modules/book/book.admin.inc
+++ b/core/modules/book/book.admin.inc
@@ -174,10 +174,6 @@ function _book_admin_table($node, &$form) {
* @see book_admin_edit()
*/
function _book_admin_table_tree($tree, &$form) {
- // The delta must be big enough to give each node a distinct value.
- $count = count($tree);
- $delta = ($count < 30) ? 15 : intval($count / 2) + 1;
-
foreach ($tree as $data) {
$form['book-admin-' . $data['link']['nid']] = array(
'#item' => $data['link'],
@@ -191,9 +187,12 @@ function _book_admin_table_tree($tree, &$form) {
'#size' => 40,
),
'weight' => array(
- '#type' => 'weight',
+ // Using a textfield and a validator instead of a simple weight select
+ // to avoid unnecessarily oversized HTML for books with hundreds of
+ // pages.
+ '#type' => 'textfield',
+ '#element_validate' => array('element_validate_integer'),
'#default_value' => $data['link']['weight'],
- '#delta' => max($delta, abs($data['link']['weight'])),
'#title' => t('Weight for @title', array('@title' => $data['link']['title'])),
'#title_display' => 'invisible',
),
diff --git a/core/modules/book/book.module b/core/modules/book/book.module
index fee2467..de09034 100644
--- a/core/modules/book/book.module
+++ b/core/modules/book/book.module
@@ -512,10 +512,12 @@ function _book_add_form_elements(&$form, &$form_state, $node) {
// @see _book_admin_table_tree(). The weight may be larger than 15.
$form['book']['weight'] = array(
- '#type' => 'weight',
+ // Using a textfield and a validator instead of a simple weight select to
+ // avoid unnecessarily oversized HTML for books with hundreds of pages.
+ '#type' => 'textfield',
+ '#element_validate' => array('element_validate_integer'),
'#title' => t('Weight'),
'#default_value' => $node->book['weight'],
- '#delta' => max(15, abs($node->book['weight'])),
'#weight' => 5,
'#description' => t('Pages at a given level are ordered first by weight and then by title.'),
);