diff --git a/src/Form/EntityInlineForm.php b/src/Form/EntityInlineForm.php index e24fd8f05b5d8284aded9bdd3bc3cb315b5fd93f..235142ea0cbeac67dd119e20a85c42d77b78a867 100644 --- a/src/Form/EntityInlineForm.php +++ b/src/Form/EntityInlineForm.php @@ -183,6 +183,9 @@ class EntityInlineForm implements InlineFormInterface { public function entityForm(array $entity_form, FormStateInterface $form_state) { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $entity_form['#entity']; + + $this->prepareInvokeAll($entity, 'entity_prepare_form', $form_state); + $this->prepareInvokeAll($entity, $entity->getEntityTypeId() . '_prepare_form', $form_state); $form_display = $this->getFormDisplay($entity, $entity_form['#form_mode']); $form_display->buildForm($entity, $entity_form, $form_state); $entity_form['#ief_element_submit'][] = [ @@ -258,6 +261,22 @@ class EntityInlineForm implements InlineFormInterface { return $entity_form; } + /** + * Invokes the specified prepare hook variant. + * + * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * The entity object. + * @param string $hook + * The hook variant name. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. + */ + protected function prepareInvokeAll(ContentEntityInterface $entity, $hook, FormStateInterface $form_state) { + $this->moduleHandler->invokeAllWith($hook, function (callable $hook, string $module) use (&$entity, &$form_state) { + $hook($entity, 'add', $form_state); + }); + } + /** * {@inheritdoc} */