Commit c3ecc1f9 authored by catch's avatar catch
Browse files

Rollback of #589440 which needs more discussion.

parent 19b1c783
...@@ -174,6 +174,10 @@ function _book_admin_table($node, &$form) { ...@@ -174,6 +174,10 @@ function _book_admin_table($node, &$form) {
* @see book_admin_edit() * @see book_admin_edit()
*/ */
function _book_admin_table_tree($tree, &$form) { 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) { foreach ($tree as $data) {
$form['book-admin-' . $data['link']['nid']] = array( $form['book-admin-' . $data['link']['nid']] = array(
'#item' => $data['link'], '#item' => $data['link'],
...@@ -187,12 +191,9 @@ function _book_admin_table_tree($tree, &$form) { ...@@ -187,12 +191,9 @@ function _book_admin_table_tree($tree, &$form) {
'#size' => 40, '#size' => 40,
), ),
'weight' => array( 'weight' => array(
// Using a textfield and a validator instead of a simple weight select '#type' => 'weight',
// to avoid unnecessarily oversized HTML for books with hundreds of
// pages.
'#type' => 'textfield',
'#element_validate' => array('element_validate_integer'),
'#default_value' => $data['link']['weight'], '#default_value' => $data['link']['weight'],
'#delta' => max($delta, abs($data['link']['weight'])),
'#title' => t('Weight for @title', array('@title' => $data['link']['title'])), '#title' => t('Weight for @title', array('@title' => $data['link']['title'])),
'#title_display' => 'invisible', '#title_display' => 'invisible',
), ),
......
...@@ -515,12 +515,10 @@ function _book_add_form_elements(&$form, &$form_state, $node) { ...@@ -515,12 +515,10 @@ function _book_add_form_elements(&$form, &$form_state, $node) {
// @see _book_admin_table_tree(). The weight may be larger than 15. // @see _book_admin_table_tree(). The weight may be larger than 15.
$form['book']['weight'] = array( $form['book']['weight'] = array(
// Using a textfield and a validator instead of a simple weight select to '#type' => 'weight',
// avoid unnecessarily oversized HTML for books with hundreds of pages.
'#type' => 'textfield',
'#element_validate' => array('element_validate_integer'),
'#title' => t('Weight'), '#title' => t('Weight'),
'#default_value' => $node->book['weight'], '#default_value' => $node->book['weight'],
'#delta' => max(15, abs($node->book['weight'])),
'#weight' => 5, '#weight' => 5,
'#description' => t('Pages at a given level are ordered first by weight and then by title.'), '#description' => t('Pages at a given level are ordered first by weight and then by title.'),
); );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment