Hi there! I've been playing with this module for Drupal 8 and seeing it's possible (very glad it's already fairly usable!)

Does anyone know whether configuration entities supported with the Inline Entity form? They are selectable with a normal entity reference, but when assigned to a configuration entity (I tried with language) I got an error essentially saying that the entity doesn't define a Default form.

Is this supposed to work or is it unsupported?

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

HairMachine created an issue. See original summary.

bojanz’s picture

Title: Drupal 8 Configuration Entities » Support for configuration entities
Category: Support request » Feature request

Currently unsupported.

dylan donkersgoed’s picture

Status: Active » Needs work
StatusFileSize
new8.04 KB

I've attached a basic patch that provides this functionality. So far so good, though it probably warrants a bit more testing and possible tweaks as well as some automated tests.

dylan donkersgoed’s picture

StatusFileSize
new8.76 KB
new1.99 KB

I ran into some issues with the inline entity form for config entities not submitting due to #after_build callbacks. I've attached a patch that fixes that, and also addresses #pre_render callbacks. I'm sure there's more to be done here but I'm not sure what should be done with which callbacks beyond that yet.

attisan’s picture

Status: Needs work » Needs review
StatusFileSize
new14.29 KB

when translation is enabled on host entities, TranslationHelper needs to only alter ContentEntityInterface entities. I patched TranslationHelper to work with EntityInterface instead of ContentEntityInterface and only alter ContentEntityInterface entities.

hth

Status: Needs review » Needs work
attisan’s picture

Status: Needs work » Needs review
StatusFileSize
new14.28 KB

Status: Needs review » Needs work

The last submitted patch, 7: inline_entity_form_support-for-configuration-entities-2581223-7.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jienckebd’s picture

I got the below error when using a complex IEF widget with a config entity. The attached patch has a few line change in ConfigEntityInlineForm to handle this scenario.

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">LogicException</em>: Getting the base fields is not supported for entity type Cron Job. in <em class="placeholder">Drupal\Core\Entity\EntityFieldManager-&gt;buildBaseFieldDefinitions()</em> (line <em class="placeholder">201</em> of <em class="placeholder">core/lib/Drupal/Core/Entity/EntityFieldManager.php</em>). <pre class="backtrace">Drupal\Core\Entity\EntityFieldManager-&gt;getBaseFieldDefinitions(&#039;ultimate_cron_job&#039;) (Line: 111)
Drupal\inline_entity_form\Form\EntityInlineForm-&gt;getTableFields(Array) (Line: 255)
Drupal\inline_entity_form\Plugin\Field\FieldWidget\InlineEntityFormComplex-&gt;formElement(Object, 0, Array, Array, Object) (Line: 335)
Drupal\Core\Field\WidgetBase-&gt;formSingleElement(Object, 0, Array, Array, Object) (Line: 85)
Drupal\Core\Field\WidgetBase-&gt;form(Object, Array, Object, NULL) (Line: 552)
Drupal\inline_entity_form\Plugin\Field\FieldWidget\InlineEntityFormBase-&gt;form(Object, Array, Object) (Line: 171)
Drupal\Core\Entity\Entity\EntityFormDisplay-&gt;buildForm(Object, Array, Object) (Line: 125)
Drupal\Core\Entity\ContentEntityForm-&gt;form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm-&gt;buildForm(Array, Object) (Line: 341)
Drupal\entity_normalize\Entity\Form\Content-&gt;buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 518)
Drupal\Core\Form\FormBuilder-&gt;retrieveForm(&#039;dita_deliverable_book_edit_form&#039;, Object) (Line: 275)
Drupal\Core\Form\FormBuilder-&gt;buildForm(&#039;dita_deliverable_book_edit_form&#039;, Object) (Line: 93)
Drupal\Core\Controller\FormController-&gt;getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 77)
Drupal\absso\StackMiddleware\AbssoMiddleware-&gt;handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 101)
Drupal\shield\ShieldMiddleware-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)
dieterholvoet’s picture

I fixed an issue when cancelling creating a new entity or when removing an added entity, both in the complex widget.

socialnicheguru’s picture

#10 is not applying for me

suresh prabhu parkala’s picture

Status: Needs work » Needs review
StatusFileSize
new15.68 KB

Re-rolled patch.

geek-merlin’s picture

This does not apply anymore and needs a re-roll.

An issue fork is appreciated a lot!
https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa...

Spokje made their first commit to this issue’s fork.

spokje’s picture

Rerolled patch #12 in fork

kapilv’s picture

Status: Needs work » Needs review
StatusFileSize
new15.69 KB

Status: Needs review » Needs work

The last submitted patch, 17: 2581223-17.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

spokje’s picture

Issue tags: +Needs tests
attisan’s picture

the last patch does not apply to the current module. would love to contribute but am at a hurry atm.

inline_entity_form_entity_type_build should look like this. instead, the patch is replacing the content of the first if (node).

/**
 * Implements hook_entity_type_build().
 */
function inline_entity_form_entity_type_build(array &$entity_types) {
  /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
  if (isset($entity_types['node']) && !$entity_types['node']->getHandlerClass('inline_form')) {
    $entity_types['node']->setHandlerClass('inline_form', '\Drupal\inline_entity_form\Form\NodeInlineForm');
  }

  foreach ($entity_types as &$entity_type) {
    if ($entity_type instanceof \Drupal\Core\Config\Entity\ConfigEntityTypeInterface) {
      $entity_type->setHandlerClass('inline_form', '\Drupal\inline_entity_form\Form\ConfigEntityInlineForm');
    }

    if (!$entity_type->hasHandlerClass('inline_form')) {
      $entity_type->setHandlerClass('inline_form', '\Drupal\inline_entity_form\Form\EntityInlineForm');
    }
  }
}

dwkitchen made their first commit to this issue’s fork.

jasonawant’s picture

The EntityInlineForm::getFormDisplay() parameter signature needs to updated to allow config entities like the EntityInlineForm::buildEntity method was updated in the last MR > https://git.drupalcode.org/project/inline_entity_form/-/merge_requests/2...

-   * @param \Drupal\Core\Entity\ContentEntityInterface $entity
+  * @param \Drupal\Core\Entity\EntityInterface $entity

- protected function buildEntity(array $entity_form, ContentEntityInterface $entity, FormStateInterface $form_state) {
+ protected function buildEntity(array $entity_form, EntityInterface $entity, FormStateInterface $form_state) {

  • podarok committed eaaaa4c3 on 2.0.x authored by Spokje
    Issue #2581223 by Spokje, Dylan Donkersgoed, attisan, DieterHolvoet,...
podarok’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs work » Fixed

pushed to 2.0.x
thanks

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

anpolimus’s picture

Thank you all on pushing this feature forward.
I'm testing it and can see that more or less code works, but fails on the save.
For example, I have menu as reference and want to create new and save it.
On save action I'm getting:
TypeError: Drupal\inline_entity_form\ReferenceUpgrader::upgradeEntityReferences(): Argument #1 ($entity) must be of type Drupal\Core\Entity\FieldableEntityInterface, Drupal\system\Entity\Menu given, called in /var/www/docroot/modules/contrib/inline_entity_form/src/WidgetSubmit.php on line 57 in Drupal\inline_entity_form\ReferenceUpgrader->upgradeEntityReferences() (line 46 of /var/www/docroot/modules/contrib/inline_entity_form/src/ReferenceUpgrader.php)
That is because, code of the reference save was hard-coded to work with content entities.
We have to add config entity support here:
https://git.drupalcode.org/project/inline_entity_form/-/blob/8.x-1.x/src...

martijn de wit’s picture

@anpolimus can you create a new issue ticket as follow up ?

podarok’s picture

Issue will be created, no worries. I'm also involved in this fix

anpolimus’s picture

geek-merlin’s picture

Version: 2.0.x-dev » 3.x-dev
Status: Closed (fixed) » Needs work
Related issues: +#3401656: Clean up problematic 2.x branch

Bulk reopen.

geek-merlin’s picture

This urgently needs tests before any commit. As the issue tag sais.

marelpup made their first commit to this issue’s fork.

marelpup’s picture

Hi ,

I referenced another issue asking for complex support
https://www.drupal.org/project/inline_entity_form/issues/3228086#comment...

I pushed a rebased version of 3.0 on this branch issue , I do not know if drupal git policies are okay with that
Andrii said it was needed
https://git.drupalcode.org/project/inline_entity_form/-/merge_requests/2...

proceeding to some tests

PS:
this issue is kinda related , tried to apply the same sort of rebase gaslighting but the branch is way behind the patch proposed and last proposed patch is trying to apply on a phantom commit (could'nt find the commit referenced in the index )
it should be closed in my opinion

marelpup’s picture

StatusFileSize
new0 bytes

PS2: gitlab doesnt appreciate this trickery and generates a patch incompatible with "lockable" composer version , here is a patch of pure difference (not incremental as gitlab proposes)

marelpup’s picture

StatusFileSize
new16.39 KB
svicer’s picture

I have tested the fix in the PR https://github.com/YCloudYUSA/yusaopeny/pull/292 in yusaopeny distro and can confirm patch #36 works correctly. The test involved creating a custom block from a landing page.

Error in logs Before Patch:

LogicException: Getting the base fields is not supported for entity type Menu. in Drupal\Core\Entity\EntityFieldManager->buildBaseFieldDefinitions() (line 225 of /srv/drupal11/docroot/core/lib/Drupal/Core/Entity/EntityFieldManager.php).

Result:

Before patch: Adding a block generated a 500 error, and the AJAX request failed.

After patch: Adding a block works as expected.