error with Entity Reference fields

Created on 13 February 2023, almost 2 years ago
Updated 12 June 2023, over 1 year ago

Hi!

I cannot create entity reference fields as first subfield. In the edit tab of the datafield field I can select "Content" as entity reference type, but I cannot set the bundle. I tried it with "entiy reference" and others, but whenever I want to specifiy the entity reference type I get a white screen error message when I try to save settings.

admin/structure/types/manage/article/fields/node.article.field_tesr
Message	Error: Cannot unset string offsets in Drupal\Core\Field\WidgetBase->extractFormValues() (line 386 of /home/xyz/public_html/staging/web/core/lib/Drupal/Core/Field/WidgetBase.php)
#0 /home/xyz/public_html/staging/web/core/lib/Drupal/Core/Field/FieldItemList.php(303): Drupal\Core\Field\WidgetBase->extractFormValues()
#1 /home/xyz/public_html/staging/web/core/modules/field_ui/src/Form/FieldConfigEditForm.php(182): Drupal\Core\Field\FieldItemList->defaultValuesFormValidate()
#2 [internal function]: Drupal\field_ui\Form\FieldConfigEditForm->validateForm()
#3 /home/xyz/public_html/staging/web/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array()
💬 Support request
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

🇦🇹Austria coreteamvn

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @coreteamvn
  • 🇫🇷France lazzyvn paris

    you should setup in widget and formatter (just click setting and save)

  • 🇦🇹Austria coreteamvn

    Thanks for the quick reply.

    The rows are there, but there is no autocomplete widget to choose the entites from on the node/add page. see dataField screenshot. There is also warning

    Location	/node/add/article?_wrapper_format=drupal_ajax&ajax_form=1
    Referrer	/node/add/article
    Warning: Undefined array key "label_display" in Drupal\datafield\Plugin\Field\FieldWidget\DataField->formElement() (line 43 of /home/xyz/public_html/staging/web/modules/contrib/datafield/src/Plugin/Field/FieldWidget/DataField.php)
    #0 /home/xyz/public_html/staging/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real()
    #1 /home/colljgpc/public_html/staging/web/modules/contrib/datafield/src/Plugin/Field/FieldWidget/DataField.php(43): _drupal_error_handler()
    #2 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/Field/WidgetBase.php(353): Drupal\datafield\Plugin\Field\FieldWidget\DataField->formElement()
    #3 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/Field/WidgetBase.php(220): Drupal\Core\Field\WidgetBase->formSingleElement()
    #4 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/Field/WidgetBase.php(111): Drupal\Core\Field\WidgetBase->formMultipleElements()
    #5 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(183): Drupal\Core\Field\WidgetBase->form()
    #6 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(121): Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm()
    #7 /home/colljgpc/public_html/staging/web/core/modules/node/src/NodeForm.php(127): Drupal\Core\Entity\ContentEntityForm->form()
    #8 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/Entity/EntityForm.php(106): Drupal\node\NodeForm->form()
    #9 [internal function]: Drupal\Core\Entity\EntityForm->buildForm()
    #10 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/Form/FormBuilder.php(534): call_user_func_array()
    #11 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/Form/FormBuilder.php(373): Drupal\Core\Form\FormBuilder->retrieveForm()
    #12 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/Form/FormBuilder.php(631): Drupal\Core\Form\FormBuilder->rebuildForm()
    #13 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/Form/FormBuilder.php(323): Drupal\Core\Form\FormBuilder->processForm()
    #14 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
    #15 /home/colljgpc/public_html/staging/web/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult()
    #16 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
    #17 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
    #18 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #19 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
    #20 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
    #21 /home/colljgpc/public_html/staging/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #22 /home/colljgpc/public_html/staging/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
    #23 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
    #24 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
    #25 /home/colljgpc/public_html/staging/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
    #26 /home/colljgpc/public_html/staging/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
    #27 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
    #28 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
    #29 /home/colljgpc/public_html/staging/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
    #30 /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/DrupalKernel.php(713): Stack\StackedHttpKernel->handle()
    #31 /home/colljgpc/public_html/staging/web/index.php(19): Drupal\Core\DrupalKernel->handle()
    #32 {main}
    .
  • 🇦🇹Austria coreteamvn

    When I now go back and try to select the entity type, i get an unspecified error and white screen.

    The error log shows this:

    admin/structure/types/manage/article/fields/node.article.field_testing
    Referrer	/admin/structure/types/manage/article/fields
    Message	InvalidArgumentException: Missing required #autocreate['bundle'] parameter. in Drupal\Core\Entity\Element\EntityAutocomplete::processEntityAutocomplete() (line 167 of /home/colljgpc/public_html/staging/web/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php).
  • 🇫🇷France lazzyvn paris

    You make me confuse
    First step

    when back i have bundle

    there ain't error in my test

  • 🇦🇹Austria coreteamvn

    ok, then i misunderstood you. now it works.

    I needed to
    1) create the datafield
    2) in the second step (where one can give the datafield a label), select for example "Content" as "entity reference type"
    3) click "Save settings"
    4) go back to 2
    5) refresh the page (only afterwards the bundle "article" showed up in my case) and set the bundle
    6) in "manage form display" go to the widget's details (e.g. autocomplete) and click "update"

    I did not make step 6, so nothing showed up.

    thanks for this useful module

  • Status changed to Closed: works as designed almost 2 years ago
  • 🇧🇪Belgium Belba

    First of all I would like to thank the builder of this module. This is a beautiful module with huge potential.

    Is there already a solution for this problem? I tested the module in Drupal 10. PHP 8.1. Most of the fields I've tried so far work flawlessly.

    However, I can't get the entity reference to work. In the first part I set the fields for the database, then I tried with both multiple values and limited values1. The next step I tried to select both entity reference and taxonomy term. There is a description : Save and back again to select bundle. When I save, I can't return, a white page with error appears : The website encountered an unexpected error. Please try again later.

    I have added the data field to an article. Existing articles can no longer be edited. New articles can no longer be created. When I check the database, the table is created, but I don't see a column with target id.

    The log message states the following:
    InvalidArgumentException: Missing required #autocreate['bundle'] parameter.

  • 🇫🇷France lazzyvn paris

    Hi you can check dev version it fixed in custom entity type, I think

Production build 0.71.5 2024