Index: modules/book/book.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.admin.inc,v retrieving revision 1.31 diff -u -p -r1.31 book.admin.inc --- modules/book/book.admin.inc 9 Jan 2010 21:54:00 -0000 1.31 +++ modules/book/book.admin.inc 18 Jan 2010 22:23:02 -0000 @@ -165,7 +165,13 @@ function _book_admin_table($node, &$form '#type' => 'value', '#value' => $hash, ); - _book_admin_table_tree($tree['below'], $form['table']); + // Delta needs to be an integer greater than 15 for consistency with the UI + // elsewhere and greater than half the number of nodes in the book. + $delta = ceil(count($tree['below']) / 2) + 1; + if ($delta < 15) { + $delta = 15; + } + _book_admin_table_tree($tree['below'], $form['table'], $delta); } } @@ -175,7 +181,7 @@ function _book_admin_table($node, &$form * * @see book_admin_edit() */ -function _book_admin_table_tree($tree, &$form) { +function _book_admin_table_tree($tree, &$form, $delta) { foreach ($tree as $data) { $form['book-admin-' . $data['link']['nid']] = array( '#item' => $data['link'], @@ -191,7 +197,7 @@ function _book_admin_table_tree($tree, & 'weight' => array( '#type' => 'weight', '#default_value' => $data['link']['weight'], - '#delta' => 15, + '#delta' => $delta, ), 'plid' => array( '#type' => 'textfield', @@ -204,7 +210,7 @@ function _book_admin_table_tree($tree, & ), ); if ($data['below']) { - _book_admin_table_tree($data['below'], $form); + _book_admin_table_tree($data['below'], $form, $delta); } } Index: modules/book/book.module =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.module,v retrieving revision 1.536 diff -u -p -r1.536 book.module --- modules/book/book.module 9 Jan 2010 21:54:00 -0000 1.536 +++ modules/book/book.module 18 Jan 2010 22:23:06 -0000 @@ -497,12 +497,18 @@ function _book_add_form_elements(&$form, } $form['book']['plid'] = _book_parent_select($node->book); + // Delta needs to be an integer greater than 15 for consistency with the UI + // elsewhere and greater than half the number of nodes in the book. + $delta = ceil(db_query('SELECT COUNT(nid) - 1 FROM {book} WHERE bid = :bid', array(':bid' => $node->book['bid']))->fetchField() / 2) + 1; + if ($delta < 15) { + $delta = 15; + } $form['book']['weight'] = array( '#type' => 'weight', '#title' => t('Weight'), '#default_value' => $node->book['weight'], - '#delta' => 15, + '#delta' => $delta, '#weight' => 5, '#description' => t('Pages at a given level are ordered first by weight and then by title.'), );