You are here

function entity_hierarchy_entity_type_build in Entity Reference Hierarchy 8

Same name and namespace in other branches
  1. 8.2 entity_hierarchy.module \entity_hierarchy_entity_type_build()
  2. 3.x entity_hierarchy.module \entity_hierarchy_entity_type_build()

Implements Here we're adding a form controller class for a custom node form without overriding the default node form.

More specifically, we're adding a children form to a tab named children. This routing information for this tab is set in the .routing.yml file, and the .links.task.yml file.

See also

hook_entity_type_build().

\Drupal\entity_hierarchy\Form\NodehierarchyChildrenForm

File

./entity_hierarchy.module, line 102
A module to make nodes hierarchical.

Code

function entity_hierarchy_entity_type_build(array &$entity_types) {

  /** @type $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
  $entity_types['node']
    ->setFormClass('entity_hierarchy_children', 'Drupal\\entity_hierarchy\\Form\\NodehierarchyChildrenForm')
    ->setLinkTemplate('entity_hierarchy-children-form', '/node/{node}/children');
}