diff --git a/inline_entity_form.module b/inline_entity_form.module index 3ccfaaa6bed52ffa7d544ed777db5267448f2a9e..9eb5e8559a57e95eb27c7428c67ab7b5640e2dc6 100644 --- a/inline_entity_form.module +++ b/inline_entity_form.module @@ -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; } diff --git a/src/Form/EntityInlineForm.php b/src/Form/EntityInlineForm.php index 9f59c013e291d1f73faa298e1f6d8ed030e91e0d..b767601c0a371f58df660771f5d0fc37afd9948c 100644 --- a/src/Form/EntityInlineForm.php +++ b/src/Form/EntityInlineForm.php @@ -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);