You are here

public function BookOutlineForm::form in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/book/src/Form/BookOutlineForm.php \Drupal\book\Form\BookOutlineForm::form()

Gets the actual form array to be built.

Overrides ContentEntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

core/modules/book/src/Form/BookOutlineForm.php, line 68
Contains \Drupal\book\Form\BookOutlineForm.

Class

BookOutlineForm
Displays the book outline form.

Namespace

Drupal\book\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form['#title'] = $this->entity
    ->label();
  if (!isset($this->entity->book)) {

    // The node is not part of any book yet - set default options.
    $this->entity->book = $this->bookManager
      ->getLinkDefaults($this->entity
      ->id());
  }
  else {
    $this->entity->book['original_bid'] = $this->entity->book['bid'];
  }

  // Find the depth limit for the parent select.
  if (!isset($this->entity->book['parent_depth_limit'])) {
    $this->entity->book['parent_depth_limit'] = $this->bookManager
      ->getParentDepthLimit($this->entity->book);
  }
  $form = $this->bookManager
    ->addFormElements($form, $form_state, $this->entity, $this
    ->currentUser(), FALSE);
  return $form;
}