3 namespace Drupal\Core\Entity;
8 * This is like \Drupal\Core\Form\FormBuilderInterface but instead of looking
9 * up the form class by class name, it looks up the form class based on the
10 * entity type and operation.
12 interface EntityFormBuilderInterface {
15 * Gets the built and processed entity form for the given entity.
17 * The form may also be retrieved from the cache if the form was built in a
18 * previous page load. The form is then passed on for processing, validation,
19 * and submission if there is proper input.
21 * @param \Drupal\Core\Entity\EntityInterface $entity
22 * The entity to be created or edited.
23 * @param string $operation
24 * (optional) The operation identifying the form variation to be returned.
25 * Defaults to 'default'. This is typically used in routing:
27 * _entity_form: node.book_outline
29 * where "book_outline" is the value of $operation. The class name for the
30 * form for each operation (edit, delete, etc.) can be found in the form
31 * section of the handlers entity annotation. For example:
35 * "delete" = "Drupal\node\Form\NodeDeleteForm",
37 * Alternatively, the form class can be set from hook_entity_type_build().
38 * @param array $form_state_additions
39 * (optional) An associative array used to build the current state of the
40 * form. Use this to pass additional information to the form, such as the
41 * langcode. Defaults to an empty array.
44 * $form_state_additions['langcode'] = $langcode;
45 * $form = \Drupal::service('entity.form_builder')->getForm($entity, 'default', $form_state_additions);
49 * The processed form for the given entity and operation.
51 * @see \Drupal\Core\Form\FormBuilderInterface::getForm()
52 * @see \Drupal\Core\Entity\EntityTypeInterface::getFormClass()
53 * @see \Drupal\Core\Entity\EntityTypeInterface::setFormClass()
54 * @see system_entity_type_build()
56 public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = []);