Problem/Motivation

Currently, the widget provided by this module extends Inline Entity Form's "InlineEntityFormComplex" widget. Much of the functionality in the widget is focused on restructuring what is provided by Inline Entity Form to work with the Layouts API, leading to verbose, complicated code. This makes the widget inherently hard to maintain and somewhat fragile, as it depends on the specific structure produced by IEF.

Proposed resolution

Replace the existing widget with a new, simpler one that doesn't depend on IEF.

Remaining tasks

Provide patches with WIP until sufficiently stable for dev branch.

User interface changes

None.

API changes

Once stable this will be a non-API-breaking change.

Data model changes

None.

Release notes snippet

TBD

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

justin2pin created an issue. See original summary.

justin2pin’s picture

Issue summary: View changes

Thinking through this more, I think we should replace the existing widget rather than add a new one, since the ultimate goal is removing the IEF dependency altogether. I'm changing the issue summary to note as much.

justin2pin’s picture

Patch attached.

Notes:

This is a complete rewrite of the field widget class, removing the dependency on Inline Entity Form. The ERL widget no longer extends IEF; it simply extends core WidgetBase.

The widget plugin source code should be cleaner, easier to understand, easier to maintain, and slightly faster from a performance perspective. Rather than modifying (i.e. wrestling with) IEF output to get the desired results, we're just building exactly the structure we need.

By default, this version does not show the Layout Options form originally provided by this module. Rather, it expects layout options to be handled by layout plugins themselves. However, to ensure this change is non-api-breaking, there is an option in the field display configuration to "Always show layout options form".

Next Steps:

This needs to be thoroughly tested in a variety of contexts before being committed to the main branch. We plan to continue testing in a number of projects underway, but appreciate any additional help!!

justin2pin’s picture

Status: Active » Needs review
BramDriesen’s picture

Warning: array_diff(): Expected parameter 1 to be an array, null given in Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements() (line 252 of modules/contrib/entity_reference_layout/src/Plugin/Field/FieldWidget/EntityReferenceLayoutWidget.php).
Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements(Object, Array, Object) (Line: 104)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 177)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object, Array, Object) (Line: 125)
Drupal\Core\Entity\ContentEntityForm->form(Array, Object) (Line: 127)
Drupal\node\NodeForm->form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 519)
Drupal\Core\Form\FormBuilder->retrieveForm('node_front_page_form', Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('node_front_page_form', Object) (Line: 61)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 129)
Drupal\node\Controller\NodeController->add(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Warning: Invalid argument supplied for foreach() in Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements() (line 253 of modules/contrib/entity_reference_layout/src/Plugin/Field/FieldWidget/EntityReferenceLayoutWidget.php).
Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements(Object, Array, Object) (Line: 104)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 177)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object, Array, Object) (Line: 125)
Drupal\Core\Entity\ContentEntityForm->form(Array, Object) (Line: 127)
Drupal\node\NodeForm->form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 519)
Drupal\Core\Form\FormBuilder->retrieveForm('node_front_page_form', Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('node_front_page_form', Object) (Line: 61)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 129)
Drupal\node\Controller\NodeController->add(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Got 2 warnings thrown

BramDriesen’s picture

This results in not being able to create sections:

Screenshot

BramDriesen’s picture

Wanting to edit an existing ERL field results in a fatal error:

The website encountered an unexpected error. Please try again later.
Error: Call to a member function get() on null in Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements() (line 206 of modules/contrib/entity_reference_layout/src/Plugin/Field/FieldWidget/EntityReferenceLayoutWidget.php).
Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements(Object, Array, Object) (Line: 104)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 287)
Drupal\Core\Field\FieldItemList->defaultValuesForm(Array, Object) (Line: 127)
Drupal\field_ui\Form\FieldConfigEditForm->form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 519)
Drupal\Core\Form\FormBuilder->retrieveForm('field_config_edit_form', Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('field_config_edit_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
BramDriesen’s picture

Creating a new ERL field throws the following warnings/notices:

Notice: Undefined index: layout_bundles in Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements() (line 179 of modules/contrib/entity_reference_layout/src/Plugin/Field/FieldWidget/EntityReferenceLayoutWidget.php).
Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements(Object, Array, Object) (Line: 104)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 287)
Drupal\Core\Field\FieldItemList->defaultValuesForm(Array, Object) (Line: 127)
Drupal\field_ui\Form\FieldConfigEditForm->form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 519)
Drupal\Core\Form\FormBuilder->retrieveForm('field_config_edit_form', Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('field_config_edit_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Notice: Undefined index: target_bundles in Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements() (line 180 of modules/contrib/entity_reference_layout/src/Plugin/Field/FieldWidget/EntityReferenceLayoutWidget.php).
Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements(Object, Array, Object) (Line: 104)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 287)
Drupal\Core\Field\FieldItemList->defaultValuesForm(Array, Object) (Line: 127)
Drupal\field_ui\Form\FieldConfigEditForm->form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 519)
Drupal\Core\Form\FormBuilder->retrieveForm('field_config_edit_form', Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('field_config_edit_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Notice: Undefined index: layout_bundles in Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formElement() (line 295 of modules/contrib/entity_reference_layout/src/Plugin/Field/FieldWidget/EntityReferenceLayoutWidget.php).
Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formElement(Object, 0, Array, Array, Object) (Line: 335)
Drupal\Core\Field\WidgetBase->formSingleElement(Object, 0, Array, Array, Object) (Line: 202)
Drupal\Core\Field\WidgetBase->formMultipleElements(Object, Array, Object) (Line: 216)
Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements(Object, Array, Object) (Line: 104)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 287)
Drupal\Core\Field\FieldItemList->defaultValuesForm(Array, Object) (Line: 127)
Drupal\field_ui\Form\FieldConfigEditForm->form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 519)
Drupal\Core\Form\FormBuilder->retrieveForm('field_config_edit_form', Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('field_config_edit_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Notice: Undefined index: layout_bundles in Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formElement() (line 295 of modules/contrib/entity_reference_layout/src/Plugin/Field/FieldWidget/EntityReferenceLayoutWidget.php).
Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formElement(Object, 1, Array, Array, Object) (Line: 335)
Drupal\Core\Field\WidgetBase->formSingleElement(Object, 1, Array, Array, Object) (Line: 202)
Drupal\Core\Field\WidgetBase->formMultipleElements(Object, Array, Object) (Line: 216)
Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements(Object, Array, Object) (Line: 104)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 287)
Drupal\Core\Field\FieldItemList->defaultValuesForm(Array, Object) (Line: 127)
Drupal\field_ui\Form\FieldConfigEditForm->form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 519)
Drupal\Core\Form\FormBuilder->retrieveForm('field_config_edit_form', Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('field_config_edit_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Warning: Invalid argument supplied for foreach() in Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements() (line 230 of modules/contrib/entity_reference_layout/src/Plugin/Field/FieldWidget/EntityReferenceLayoutWidget.php).
Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements(Object, Array, Object) (Line: 104)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 287)
Drupal\Core\Field\FieldItemList->defaultValuesForm(Array, Object) (Line: 127)
Drupal\field_ui\Form\FieldConfigEditForm->form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 519)
Drupal\Core\Form\FormBuilder->retrieveForm('field_config_edit_form', Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('field_config_edit_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Warning: array_diff(): Expected parameter 1 to be an array, null given in Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements() (line 252 of modules/contrib/entity_reference_layout/src/Plugin/Field/FieldWidget/EntityReferenceLayoutWidget.php).
Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements(Object, Array, Object) (Line: 104)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 287)
Drupal\Core\Field\FieldItemList->defaultValuesForm(Array, Object) (Line: 127)
Drupal\field_ui\Form\FieldConfigEditForm->form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 519)
Drupal\Core\Form\FormBuilder->retrieveForm('field_config_edit_form', Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('field_config_edit_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Warning: Invalid argument supplied for foreach() in Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements() (line 253 of modules/contrib/entity_reference_layout/src/Plugin/Field/FieldWidget/EntityReferenceLayoutWidget.php).
Drupal\entity_reference_layout\Plugin\Field\FieldWidget\EntityReferenceLayoutWidget->formMultipleElements(Object, Array, Object) (Line: 104)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 287)
Drupal\Core\Field\FieldItemList->defaultValuesForm(Array, Object) (Line: 127)
Drupal\field_ui\Form\FieldConfigEditForm->form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 519)
Drupal\Core\Form\FormBuilder->retrieveForm('field_config_edit_form', Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('field_config_edit_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

BramDriesen’s picture

Status: Needs review » Needs work

And after saving the new field, I can add layout paragraphs, but you can't add paragraphs into the layout since you the "+" Icon isn't populated.

Also the grey background seems to be missing in the CSS making the UI difficult to see (on node edit/add pages)

BramDriesen’s picture

FileSize
3.53 KB
124.56 KB

I updated the patch a little bit. I had to include the patch from #3045458: Configuration error when changing bundles in field config as well since otherwise the settings form would be broken. My patch fixes the fatal errors & warnings however I noticed that the "+" button isn't being populated with the add paragraph settings when you selected the Exclude setting. Only include seems to be working for now. A lot of the CSS also seems to be broken and needs some work. I fixed the background colour.

Attached interdiff & patch, leaving on needs work since it's obviously not ready yet.

BramDriesen’s picture

FileSize
124.58 KB
739 bytes

Fixed the fatal error when editing an existing ERL field.

BramDriesen’s picture

Also the nesting issue from issue #3067550: ERL doesn't work inside a paragraph is not resolved with the new widget. If you try to add a layout in a ERL field which is placed in a paragraph, you get the following error which I couldn't trace back yet to the root cause.

Drupal.AjaxError {message: "↵An AJAX HTTP error occurred.↵HTTP Result Code: 20…Drupal/Core/Render/MainContent/AjaxRenderer.php).", name: "AjaxError"}
message: "↵An AJAX HTTP error occurred.↵HTTP Result Code: 200↵Debugging information follows.↵Path: /fr/node/add/page?ajax_form=1↵StatusText: parsererror↵ResponseText: TypeError: Argument 1 passed to Drupal\Core\Render\MainContent\AjaxRenderer::renderResponse() must be of the type array, null given, called in /app/web/core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php on line 89 in Drupal\Core\Render\MainContent\AjaxRenderer->renderResponse() (line 38 of /app/web/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php)."
name: "AjaxError"
justin2pin’s picture

Status: Needs work » Needs review
FileSize
122.04 KB
7.73 KB

@BramDriesen Thanks for all of this! I spent some time bringing CSS styles back inline with how they were working previously. There are a few very minor changes (hopefully improvements) with the new CSS, but please let me know if you notice any issues.

Setting this to "Needs review," although I'm going to continue investigating the other issue you posted in #12 above.

-Justin

justin2pin’s picture

FileSize
122.14 KB
7.79 KB

Of course I posted too soon -- noticed an issue where "Add Section" wasn't showing up for new content.

justin2pin’s picture

Updated patch - hoping to address #12 and #3067550: ERL doesn't work inside a paragraph. There were a number of issues with the new widget when multiple ERL fields are present on a single edit screen. I'm continuing to track those issues here -- rather than opening a separate issue -- since they are bugs with the new widget (although they are likely problems in the current widget as well).

lexsoft00’s picture

Hi,

Patch fails on latest dev version.

docroot/modules/contrib/entity_reference_layout$ patch -p1 < en entity_reference_layout-remove_ief-3068270-15.patch
patching file css/erl-widget.css (already renamed from css/entity-reference-layout.css)
Reversed (or previously applied) patch detected!  Assume -R? [n]
Apply anyway? [n] y
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 173.
Hunk #3 FAILED at 217.
Hunk #4 FAILED at 248.
Hunk #5 FAILED at 264.
Hunk #6 FAILED at 279.
Hunk #7 FAILED at 303.
7 out of 7 hunks FAILED -- saving rejects to file css/erl-widget.css.rej
The next patch would delete the file css/full-screen-editing.css,
which does not exist!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored
patching file entity_reference_layout.libraries.yml
Reversed (or previously applied) patch detected!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file entity_reference_layout.libraries.yml.rej
patching file entity_reference_layout.module
Reversed (or previously applied) patch detected!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
5 out of 5 hunks ignored -- saving rejects to file entity_reference_layout.module.rej
The next patch would delete the file js/entity-reference-layout.js
justin2pin’s picture

@lexsoft I can't seem to reproduce that issue. Can you try patching latest dev with #15 again and let me know what happens?

lexsoft00’s picture

It works now, thanks.

entity_reference_layout$ patch -p1 < entity_reference_layout-remove_ief-3068270-15.patch
patching file css/erl-widget.css (renamed from css/entity-reference-layout.css)
patching file css/full-screen-editing.css
patching file entity_reference_layout.libraries.yml
patching file entity_reference_layout.module
patching file js/entity-reference-layout.js
patching file js/erl-widget.js
patching file src/Plugin/Field/FieldType/EntityReferenceLayoutRevisioned.php
patching file src/Plugin/Field/FieldWidget/EntityReferenceLayoutWidget.php
bgilhome’s picture

Patch working well for me, except for the minor issue that closing the modal (via close or Cancel buttons) doesn't trigger dialog beforeclose/afterclose events on the window. This caused an issue for me whereby entity_browser sets body classes on dialog open/close to prevent scrolling - the classes were added on open but not removed on ERL modal close.

Patch attached ensures that those events are triggered. Interdiff to patch in 15 also attached.

bgilhome’s picture

Another issue I found was using the 'negate' or 'exclude' option for the target bundles in the field settings - currently the widget doesn't respect the negate setting. Patch attached to fix this, along with interdiff.

BramDriesen’s picture

I tested the patch a bit and it seems to work fine (it broke some things that we custom developed, but that's fine since we were depneding on some hooks coming from IEF). It seems to be more responsive as well actually. I didn't test a nested example though.

justin2pin’s picture

@bgilhome Thanks for this - unfortunately the latest patch (#20) doesn't apply to dev after pushing the fix for #3075919: Ajax error without user permission to edit plugin config. I'm working on a separate patch for this issue that addresses a few other things we've found, and will fold in your changes as well.

Looking forward to getting this all pushed back to dev, which will simplify things in the future.

Thanks again.

justin2pin’s picture

Status: Needs review » Needs work
justin2pin’s picture

Status: Needs work » Needs review
FileSize
127.05 KB
11.28 KB

Attached patch addresses a number of issues:

Note that interdiff is from #15, since #19 and #20 no longer apply cleanly to dev.

Review and feedback would be much appreciated... would love to get his pushed to the main dev branch!

justin2pin’s picture

Priority: Normal » Major
justin2pin’s picture

FileSize
129.24 KB

Rerolled patch against latest dev.

Anybody’s picture

Thank you for this very important improvement. We just tried this patch to find out if it fixes #3079733: Nested paragraphs not translatable, but it doesn't. Now the fields to translate appear, but the widget shows "(all languages)" which is not correct for the fields in nested paragraphs so it doesn't seem to inherit the correct parent language. See the issue for details on the configuration. Perhaps a look at the paragraphs issue #2864682: Sub-paragraph fields cannot be translated is also helpful.

I thinks all regular multilanguage combinations including nesting, which is typical for many cases, should be tested to work before this is RTBC'ed. Thank you all so much for this promising work and this wonderful module!

itamair’s picture

the #26 patch doesn't apply cleanly (to me) to the actual dev HEAD (3fd9f5ace4c32134b23f5f384b0beb95afd637a9)

justin2pin’s picture

FileSize
126.96 KB

Thanks @itamair. The attached patch should be up to date with current dev HEAD.

BramDriesen’s picture

Status: Needs review » Needs work

According to #27 it's still not ready I think :)

BramDriesen’s picture

Any update Justin? :)

saschaeggi’s picture

The latest patch from #29 removes some functionality so it doesn't apply correctly.

justin2pin’s picture

Thanks @saschaeggi -- what functionality are you referring to?

@BramDriesen and @Anybody -- thanks for testing translations on this. Question: does this patch remove translation functionality that previously was working (meaning *was* work with IEF, but is *not* working with this patch)? If not, I'd like to get this pushed to dev and then track the translation issue separately.

Let me know what you think!

saschaeggi’s picture

@justin2pin classes are the old ones again, missing paragraphs icons from dev build

justin2pin’s picture

@saschaeggi - thanks and good catch re:icons, I'll get those in.

What do you mean by "classes are the old ones again" though?

saschaeggi’s picture

@justin2pin I was wrong, I just checked it again. Looks like the CSS classes used after applying the patch are according to BEM.
e.g.

After applying the path
.erl-add-content__group

Dev version:
.erl-add-content--group

So that's very nice. I tested it once again and the only thing (as mentioned before) are the paragraph icons which are missing now.
Maybe we can go with a nicer implementation for the selection of the elements after this. I was exploring it already a bit in this ticket here: 3070005: Implement a nicer solution to element selection

Let me know when you've fixed the icons, so I can test again :-)
Cheers

justin2pin’s picture

FileSize
128.16 KB

Thanks again @saschaeggi -- The attached patch adds support for paragraph icons.

saschaeggi’s picture

@justin2pin the patch from #37 works like a charm for me.

saschaeggi’s picture

Status: Needs work » Reviewed & tested by the community
justin2pin’s picture

Status: Reviewed & tested by the community » Fixed
FileSize
128.35 KB

Just pushed to dev. Thanks everybody for the help on this... this is a big step for this module.

Also: attached is the final patch for the pushed change. I removed the referenced requirement to IEF as well as the PATCHES.txt file generated locally by composer.

itamair’s picture

Status: Fixed » Patch (to be ported)

Ehi ... I haven't got the evidence that this have been pushed into dev yet, isn't it?
Be sure to add the below preset message into the patch porting commit, or at least the 'Issue #3068270 ... ' issue reference.

itamair’s picture

Status: Patch (to be ported) » Fixed
itamair’s picture

itamair’s picture

Just to be and make it more clear, also to others maintainers and developers that clone the GIT dev repository, once an issue is closed and tagged as Fixed as a consequence of the porting of the best packed patch, its commit message should be populated with the "Issue #number ... "
to give a clear reference of the commit itself and the issue that generated it.

In this case it would be (as preset here under in the "Credit and committing" section:

'Issue #3068270 by justin2pin, BramDriesen, bgilhome, saschaeggi, itamair, lexsoft, Anybody: Remove Inline Entity Form module dependency' --author="justin2pin "

This will add a clear mention and link (to the commit) in the issue thread itself, and would give a clear reference of the issue that originated that commit in the Repo Commits history.

In same cases more than commit might be tagged with the same "Issue #number ... " if all incremental amends related to the same issue.

justin2pin’s picture

Thanks @itamair -- my mistake! I had been working on this in a separate branch and and just merged my work without actually applying that latest patch. Will make make sure to just apply the patch and use the right commit message in the future :).

Status: Fixed » Closed (fixed)

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