Skip to content
Snippets Groups Projects
Commit e486d9e6 authored by Eugene Brit's avatar Eugene Brit Committed by Andrii Podanenko
Browse files

Issue #3015323 by ziomizar, eugene.brit, Musa.thomas: IEF does not invoke hook_entity_prepare_form

parent 0d186588
No related branches found
No related tags found
No related merge requests found
......@@ -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}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment