You are here

function _book_parent_select in Drupal 6

Same name and namespace in other branches
  1. 7 modules/book/book.module \_book_parent_select()

Build the parent selection form element for the node form or outline tab

This function is also called when generating a new set of options during the AJAX callback, so an array is returned that can be used to replace an existing form element.

2 calls to _book_parent_select()
book_form_update in modules/book/book.pages.inc
Renders a new parent page select element when the book selection changes.
_book_add_form_elements in modules/book/book.module
Build the common elements of the book form for the node and outline forms.

File

modules/book/book.module, line 321
Allows users to structure the pages of a site in a hierarchy or outline.

Code

function _book_parent_select($book_link) {
  if (variable_get('menu_override_parent_selector', FALSE)) {
    return array();
  }

  // Offer a message or a drop-down to choose a different parent page.
  $form = array(
    '#type' => 'hidden',
    '#value' => -1,
    '#prefix' => '<div id="edit-book-plid-wrapper">',
    '#suffix' => '</div>',
  );
  if ($book_link['nid'] === $book_link['bid']) {

    // This is a book - at the top level.
    if ($book_link['original_bid'] === $book_link['bid']) {
      $form['#prefix'] .= '<em>' . t('This is the top-level page in this book.') . '</em>';
    }
    else {
      $form['#prefix'] .= '<em>' . t('This will be the top-level page in this book.') . '</em>';
    }
  }
  elseif (!$book_link['bid']) {
    $form['#prefix'] .= '<em>' . t('No book selected.') . '</em>';
  }
  else {
    $form = array(
      '#type' => 'select',
      '#title' => t('Parent item'),
      '#default_value' => $book_link['plid'],
      '#description' => t('The parent page in the book. The maximum depth for a book and all child pages is !maxdepth. Some pages in the selected book may not be available as parents if selecting them would exceed this limit.', array(
        '!maxdepth' => MENU_MAX_DEPTH,
      )),
      '#options' => book_toc($book_link['bid'], array(
        $book_link['mlid'],
      ), $book_link['parent_depth_limit']),
      '#attributes' => array(
        'class' => 'book-title-select',
      ),
    );
  }
  return $form;
}