function BookOutlineForm::form

Same name in other branches
  1. 9 core/modules/book/src/Form/BookOutlineForm.php \Drupal\book\Form\BookOutlineForm::form()
  2. 10 core/modules/book/src/Form/BookOutlineForm.php \Drupal\book\Form\BookOutlineForm::form()
  3. 11.x core/modules/book/src/Form/BookOutlineForm.php \Drupal\book\Form\BookOutlineForm::form()

Overrides ContentEntityForm::form

File

core/modules/book/src/Form/BookOutlineForm.php, line 74

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.