protected BookManager::addParentSelectFormElements(array $book_link)
Builds 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.
Parameters
array $book_link: A fully loaded book link that is part of the book hierarchy.
Return value
array A parent selection form element.
File
- core/modules/book/src/BookManager.php, line 325
Class
- BookManager
- Defines a book manager.
Namespace
Drupal\book
Code
protected function addParentSelectFormElements(array $book_link) { $config = $this->configFactory->get('book.settings'); if ($config->get('override_parent_selector')) { 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>' . $this->t('This is the top-level page in this book.') . '</em>'; } else { $form['#prefix'] .= '<em>' . $this->t('This will be the top-level page in this book.') . '</em>'; } } elseif (!$book_link['bid']) { $form['#prefix'] .= '<em>' . $this->t('No book selected.') . '</em>'; } else { $form = array( '#type' => 'select', '#title' => $this->t('Parent item'), '#default_value' => $book_link['pid'], '#description' => $this->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' => static::BOOK_MAX_DEPTH)), '#options' => $this->getTableOfContents($book_link['bid'], $book_link['parent_depth_limit'], array($book_link['nid'])), '#attributes' => array('class' => array('book-title-select')), '#prefix' => '<div id="edit-book-plid-wrapper">', '#suffix' => '</div>', ); } $this->renderer->addCacheableDependency($form, $config); return $form; }
Please login to continue.