CurrentFormDataProvider does not accept Entity References

Problem/Motivation

If we have an entity form with a taxonomy field as an entity reference, you can set in the Managed Fields: Create referenced entities if they don`t exist yet.

If we save the form with a new taxonomy value, and we have an ECA model that performs a pre-save event for instance, the following error occurs:

The website encountered an unexpected error. Please try again later.
Error: Object of class Drupal\taxonomy\Entity\Term could not be converted to string in Drupal\eca_form\Token\CurrentFormDataProvider->Drupal\eca_form\Token\{closure}() (line 76 of modules/contrib/eca/modules/form/src/Token/CurrentFormDataProvider.php).
Drupal\eca_form\Token\CurrentFormDataProvider->Drupal\eca_form\Token\{closure}()
array_walk_recursive() (Line: 77)
Drupal\eca_form\Token\CurrentFormDataProvider->getData() (Line: 96)
Drupal\eca_form\Token\CurrentFormDataProvider->hasData() (Line: 247)
Drupal\eca\Token\ContribToken->getTokenData() (Line: 225)
Drupal\eca\Token\ContribToken->hasTokenData() (Line: 293)
Drupal\eca\Token\ContribToken->generate() (Line: 239)
Drupal\Core\Utility\Token->doReplace() (Line: 189)
Drupal\Core\Utility\Token->replace() (Line: 348)
Drupal\eca\Token\ContribToken->replace() (Line: 135)
Drupal\eca\Token\TokenServices->replace() (Line: 143)
Drupal\eca\Token\TokenServices->replaceClear() (Line: 53)
Drupal\eca_tamper\Plugin\Action\Tamper->execute() (Line: 102)
Drupal\eca\Entity\Objects\EcaAction->execute() (Line: 188)
Drupal\eca\Processor->executeSuccessors() (Line: 146)
Drupal\eca\Processor->execute() (Line: 76)
Drupal\eca\EventSubscriber\EcaBase->onEvent()
call_user_func() (Line: 110)
Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher->dispatch() (Line: 73)
Drupal\eca\Event\TriggerEvent->dispatchFromPlugin() (Line: 132)
Drupal\eca_form\HookHandler::validate()
call_user_func_array() (Line: 82)
Drupal\Core\Form\FormValidator->executeValidateHandlers() (Line: 275)
Drupal\Core\Form\FormValidator->doValidateForm() (Line: 118)
Drupal\Core\Form\FormValidator->validateForm() (Line: 591)
Drupal\Core\Form\FormBuilder->processForm() (Line: 323)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 38)
Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 718)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Proposed resolution

In method array_walk_recursive, we have to check whether this is an entity reference, which cannot be cast to a string.

Edited by drupalbot
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information