Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
As a site builder, I want to allow the creation of blocks on an entity, where these blocks will be single use. This is similar to adding blocks in layout_builder and the block type involved is InlineBlock. This issue is not about using layout builder though, it happens that layout builder provides the InlineBlock plugin.
I've added a general question about my problem on stack exchange as well.
Steps to reproduce
- Install block_field, layout_builder
- Create a custom block type with one field, just some text
- (Do not create any blocks in the custom block library)
- New node type "page"
- Add a block_field field to "page", and reference the new plugin, which will be type "inline block" (provider is Layout Builder)
- Create a node, populate by choose the block type and filling in the form.
- Hit save
Resulting error :
The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to Drupal\Component\Utility\NestedArray::getValue() must be of the type array, null given, called in /app/web/core/lib/Drupal/Core/Field/WidgetBase.php on line 414 in Drupal\Component\Utility\NestedArray::getValue() (line 69 of core/lib/Drupal/Component/Utility/NestedArray.php).
Drupal\Component\Utility\NestedArray::getValue(NULL, NULL) (Line: 414)
Drupal\Core\Field\WidgetBase->flagErrors(Object, Object, Array, Object) (Line: 265)
Drupal\Core\Entity\Entity\EntityFormDisplay->flagWidgetsErrorsFromViolations(Object, Array, Object) (Line: 252)
Drupal\Core\Entity\Entity\EntityFormDisplay->validateFormValues(Object, Array, Object) (Line: 181)
Drupal\layout_builder\Plugin\Block\InlineBlock->blockValidate(Array, Object) (Line: 207)
Drupal\Core\Block\BlockBase->validateConfigurationForm(Array, Object) (Line: 238)
Drupal\block_field\Plugin\Field\FieldWidget\BlockFieldWidget::validate(Array, Object, Array)
call_user_func_array(Array, Array) (Line: 280)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 236)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 236)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 236)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'node_article_form') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('node_article_form', Array, Object) (Line: 589)
Drupal\Core\Form\FormBuilder->processForm('node_article_form', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
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: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 67)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->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: 49)
Asm89\Stack\Cors->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: 705)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Proposed resolution
It would be great if this module supported the core "InlineBlock" block plugin type.
Comments
Comment #2
simeUpdated intro to specify the problem is with node fields not just paragraphs.
Comment #3
simeAdded question to Stack Exchange https://drupal.stackexchange.com/questions/299372/how-to-attach-a-new-in...
Comment #4
acbramley CreditAttribution: acbramley at PreviousNext for University of Adelaide commentedCP from SO:
What we should do here I think is hide the InlineBlock plugin from block_field's available choices.
Comment #5
simeMakes sense - thanks for the stack exchange response!
Comment #6
damondt CreditAttribution: damondt commentedI agree that removing the entity reference option for block plugins is ideal so that people will drill down to find custom block content or other block content to reference.
If others encounter this I also got errors trying to use the inline entity form, but had luck using entity browser after creating a block entity browser through the gui.
Comment #7
BerdirThe error is coming from the block plugin itself so not sure we can do something about that. That said I' don't fully agree with the answer there, because using block_field would still allow you to mix things, use a block content entity in one place and a view in another.
However, if you want inlined non-reusable content, then there might be better approaches for that than this module + InlineBlock.