I was unable to add any fields from a content type through Layout Builder with Linked Fields installed. Most of these errors were solved with the patches in #2952482: Undefined index: #type when using Token module (optional dependency) and #2987464: Linked field are not compatible with layout builder. The one that remains with those two patches applied is:

Notice: Undefined index: linked in linked_field_field_formatter_third_party_settings_form() (line 138 of /app/web/modules/contrib/linked_field/linked_field.module) #0 /app/web/core/includes/bootstrap.inc(587): _drupal_error_handler_real(8, 'Undefined index...', '/app/web/module...', 138, Array)

Callstack:

#1 /app/web/modules/contrib/linked_field/linked_field.module(138): _drupal_error_handler(8, 'Undefined index...', '/app/web/module...', 138, Array) 
#2 [internal function]: linked_field_field_formatter_third_party_settings_form(Object(Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter), Object(Drupal\field\Entity\FieldConfig), '_custom', Array, Object(Drupal\Core\Form\FormState)) 
#3 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(392): call_user_func_array('linked_field_fi...', Array) 
#4 /app/web/core/modules/layout_builder/src/Plugin/Block/FieldBlock.php(317): Drupal\Core\Extension\ModuleHandler->invoke('linked_field', 'field_formatter...', Array) 
#5 /app/web/core/modules/layout_builder/src/Plugin/Block/FieldBlock.php(282): Drupal\layout_builder\Plugin\Block\FieldBlock->thirdPartySettingsForm(Object(Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter), Object(Drupal\field\Entity\FieldConfig), Array, Object(Drupal\Core\Form\FormState)) 
#6 [internal function]: Drupal\layout_builder\Plugin\Block\FieldBlock->formatterSettingsProcessCallback(Array, Object(Drupal\Core\Form\FormState), Array) 
#7 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(998): call_user_func_array(Array, Array) 
#8 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(1061): Drupal\Core\Form\FormBuilder->doBuildForm('layout_builder_...', Array, Object(Drupal\Core\Form\FormState)) 
#9 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(1061): Drupal\Core\Form\FormBuilder->doBuildForm('layout_builder_...', Array, Object(Drupal\Core\Form\FormState)) 
#10 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(562): Drupal\Core\Form\FormBuilder->doBuildForm('layout_builder_...', Array, Object(Drupal\Core\Form\FormState)) 
#11 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(319): Drupal\Core\Form\FormBuilder->processForm('layout_builder_...', Array, Object(Drupal\Core\Form\FormState)) 
#12 /app/web/core/lib/Drupal/Core/Controller/FormController.php(93): Drupal\Core\Form\FormBuilder->buildForm('layout_builder_...', Object(Drupal\Core\Form\FormState)) 
#13 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) 
#14 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) 
#15 /app/web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() 
#16 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) 
#17 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) 
#18 /app/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() 
#19 /app/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) 
#20 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#21 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#22 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#23 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#24 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#25 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#26 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#27 /app/web/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#28 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) 
#29 {main}.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BrightBold created an issue. See original summary.

joelpittet’s picture

Status: Active » Needs review
FileSize
1.31 KB

I half fixed this already, here's the finished thing, I hope it helps!

joelpittet’s picture

The patch merges the settings on to the defaults. And the $settings array should always be an array by interface signature.

Status: Needs review » Needs work

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

joelpittet’s picture

Status: Needs work » Needs review

No tests failure

freelock’s picture

FileSize
1.91 KB

I'm getting a different error than above, but same base configuration... a bit short on time, but here's a patch that got linked fields working for me with Layout Builder...

joelpittet’s picture

Thanks freelock, I'm sure there are other little things that are gotchas. Could you explain your patch, maybe it should be in its own issue?

+++ b/linked_field.module
@@ -36,7 +36,7 @@ function linked_field_field_formatter_settings_summary_alter(&$summary, $context
-  $destination = $settings['destination'];
+  $destination = $settings['destination'][$type];

@@ -211,7 +209,7 @@ function linked_field_field_formatter_third_party_settings_form(FormatterInterfa
-    '#default_value' => $settings['destination'],
+    '#default_value' => $settings['destination']['field'],

@@ -360,7 +358,7 @@ function linked_field_entity_display_build_alter(&$build, $context) {
+    $destination = $destination[$destination_type];
joelpittet’s picture

+++ b/linked_field.module
@@ -109,16 +109,14 @@ function linked_field_field_formatter_third_party_settings_form(FormatterInterfa
-      'destination' => '',
...
+    'destination' => '',

The reason I ask is because the destination setting is expecting a string.

joelpittet’s picture

FileSize
897 bytes
+++ b/linked_field.module
@@ -297,7 +296,7 @@ function linked_field_field_formatter_third_party_settings_form(FormatterInterfa
-  $settings = \Drupal\Component\Utility\NestedArray::getValue(
+  $settings = NestedArray::getValue(

Removed this because it conflicts with my other patch and it's just cleanup. #3060776: ResponseText: Error: Cannot use object of type . This is a reroll of #2

joelpittet’s picture

FileSize
696 bytes
+++ b/linked_field.module
@@ -5,6 +5,7 @@
+use Drupal\Component\Utility\NestedArray;

This use statement is already there in dev

  • joelpittet authored 8cbe866 on 8.x-1.x
    Issue #3049135 by joelpittet: Undefined index: linked when adding fields...
yannickoo’s picture

Status: Needs review » Fixed

Thanks for the patch!

Status: Fixed » Closed (fixed)

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