function NodeController::add

Provides the node submission form.

Parameters

\Drupal\node\NodeTypeInterface $node_type: The node type entity for the node.

Return value

array A node submission form.

Deprecated

in drupal:8.8.0 and is removed from drupal:9.0.0. Define entity form routes through the _entity_form instead through the _controller directive.

File

core/modules/node/src/Controller/NodeController.php, line 129

Class

NodeController
Returns responses for Node routes.

Namespace

Drupal\node\Controller

Code

public function add(NodeTypeInterface $node_type) {
    @trigger_error(__METHOD__ . ' is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Define entity form routes through the _entity_form instead through the _controller directive. See https://www.drupal.org/node/3084856', E_USER_DEPRECATED);
    $node = $this->entityTypeManager()
        ->getStorage('node')
        ->create([
        'type' => $node_type->id(),
    ]);
    $form = $this->entityFormBuilder()
        ->getForm($node);
    return $form;
}

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