Skip to content
Snippets Groups Projects
Commit e09adf39 authored by Raf Philtjens's avatar Raf Philtjens Committed by Andrii Podanenko
Browse files

Allow themes to implement the hook_inline_entity_form_entity_form_alter() and...

Allow themes to implement the hook_inline_entity_form_entity_form_alter() and hook_inline_entity_form_reference_form_alter() hooks
parent f9627498
No related branches found
No related tags found
2 merge requests!99Closes #3359875,!31Allow themes to alter inline entity forms
......@@ -132,8 +132,9 @@ function inline_entity_form_reference_form(array $reference_form, FormStateInter
$reference_form['#element_validate'][] = 'inline_entity_form_reference_form_validate';
$reference_form['#ief_element_submit'][] = 'inline_entity_form_reference_form_submit';
// Allow other modules to alter the form.
// Allow other modules and themes to alter the form.
\Drupal::moduleHandler()->alter('inline_entity_form_reference_form', $reference_form, $form_state);
\Drupal::theme()->alter('inline_entity_form_reference_form', $reference_form, $form_state);
return $reference_form;
}
......
......@@ -14,6 +14,7 @@ use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Render\Element;
use Drupal\Core\Theme\ThemeManagerInterface;
use Drupal\inline_entity_form\InlineFormInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -52,6 +53,13 @@ class EntityInlineForm implements InlineFormInterface {
*/
protected $moduleHandler;
/**
* The theme manager.
*
* @var \Drupal\Core\Theme\ThemeManagerInterface
*/
protected $themeManager;
/**
* Constructs the inline entity form controller.
*
......@@ -63,12 +71,15 @@ class EntityInlineForm implements InlineFormInterface {
* The module handler.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
* @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager
* The theme manager.
*/
public function __construct(EntityFieldManagerInterface $entity_field_manager, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, EntityTypeInterface $entity_type) {
public function __construct(EntityFieldManagerInterface $entity_field_manager, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, EntityTypeInterface $entity_type, ThemeManagerInterface $theme_manager) {
$this->entityFieldManager = $entity_field_manager;
$this->entityTypeManager = $entity_type_manager;
$this->moduleHandler = $module_handler;
$this->entityType = $entity_type;
$this->themeManager = $theme_manager;
}
/**
......@@ -79,7 +90,8 @@ class EntityInlineForm implements InlineFormInterface {
$container->get('entity_field.manager'),
$container->get('entity_type.manager'),
$container->get('module_handler'),
$entity_type
$entity_type,
$container->get('theme.manager')
);
}
......@@ -201,8 +213,9 @@ class EntityInlineForm implements InlineFormInterface {
// Determine the children of the entity form before it has been altered.
$children_before = Element::children($entity_form);
// Allow other modules to alter the form.
// Allow other modules and themes to alter the form.
$this->moduleHandler->alter('inline_entity_form_entity_form', $entity_form, $form_state);
$this->themeManager->alter('inline_entity_form_entity_form', $entity_form, $form_state);
// Determine the children of the entity form after it has been altered.
$children_after = Element::children($entity_form);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment