0

Drupal 9.5.11

I have a Timeline component that uses three fields:

  • field_title
  • field_body
  • field_timeline

Field_timeline is a custom field with:

  • TimelineDefaultFormatter.php
  • Timeline.php
  • TimelineDefaultWidget.php

I tried to add a upload field to add an attachment file. The UI now shows the upload button but I cannot save the file.

I think the problem is in the definiton of the property

public static function propertyDefinitions(StorageDefinition $storage)
  {
    $properties = [];

    $properties['title'] = DataDefinition::create('string')
      ->setLabel(t('Title'));

    $properties['summary'] = DataDefinition::create('string')
      ->setLabel(t('Abstract'));

    $properties['date'] = DataDefinition::create('string')
      ->setLabel(t('Date'));

    $properties['attenzione'] = DataDefinition::create('string')
      ->setLabel(t('Attenzione'));

    $properties['allegato'] = DataDefinition::create('entity:file')->setLabel(t('Allegato'));

    return $properties;
  }

I tried file entity:file entity:field_item:file without success, the are always error.

The error is the following

UPDATE with full error stack trace

2024-07-23 08:46:14 [Tue Jul 23 06:46:14.075015 2024] [php:notice] [pid 35] [client 172.22.0.1:35556] Error: Call to a member function isNew() on array in /opt/drupal/web/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php on line 19 #0 /opt/drupal/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(201): Drupal\Core\Entity\Plugin\Validation\Constraint\EntityChangedConstraintValidator->validate(Array, Object(Drupal\Core\Entity\Plugin\Validation\Constraint\EntityChangedConstraint))\n#1 /opt/drupal/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(153): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateConstraints(Array, '0000000000000a5...', Array)\n#2 /opt/drupal/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(163): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object(Drupal\Core\Entity\Plugin\DataType\EntityAdapter))\n#3 /opt/drupal/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(163): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object(Drupal\timeline\Plugin\Field\FieldType\Timeline))\n#4 /opt/drupal/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(163): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object(Drupal\Core\Field\FieldItemList))\n#5 /opt/drupal/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(105): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object(Drupal\Core\Entity\Plugin\DataType\EntityAdapter), Array, true)\n#6 /opt/drupal/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php(93): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validate(Object(Drupal\Core\Entity\Plugin\DataType\EntityAdapter), NULL, NULL)\n#7 /opt/drupal/web/core/lib/Drupal/Core/TypedData/TypedData.php(132): Drupal\Core\TypedData\Validation\RecursiveValidator->validate(Object(Drupal\Core\Entity\Plugin\DataType\EntityAdapter))\n#8 /opt/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(489): Drupal\Core\TypedData\TypedData->validate()\n#9 /opt/drupal/web/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(248): Drupal\Core\Entity\ContentEntityBase->validate()\n#10 /opt/drupal/web/modules/contrib/inline_entity_form/src/Form/EntityInlineForm.php(256): Drupal\Core\Entity\Entity\EntityFormDisplay->validateFormValues(Object(Drupal\paragraphs\Entity\Paragraph), Array, Object(Drupal\Core\Form\FormState))\n#11 /opt/drupal/web/modules/contrib/inline_entity_form/src/Element/InlineEntityForm.php(167): Drupal\inline_entity_form\Form\EntityInlineForm->entityFormValidate(Array, Object(Drupal\Core\Form\FormState))\n#12 [internal function]: Drupal\inline_entity_form\Element\InlineEntityForm::validateEntityForm(Array, Object(Drupal\Core\Form\FormState), Array)\n#13 /opt/drupal/web/core/lib/Drupal/Core/Form/FormValidator.php(282): call_user_func_array(Array, Array)\n#14 /opt/drupal/web/core/lib/Drupal/Core/Form/FormValidator.php(238): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState))\n#15 /opt/drupal/web/core/lib/Drupal/Core/Form/FormValidator.php(238): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState))\n#16 /opt/drupal/web/core/lib/Drupal/Core/Form/FormValidator.php(238): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState))\n#17 /opt/drupal/web/core/lib/Drupal/Core/Form/FormValidator.php(238): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState))\n#18 /opt/drupal/web/core/lib/Drupal/Core/Form/FormValidator.php(238): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState))\n#19 /opt/drupal/web/core/lib/Drupal/Core/Form/FormValidator.php(238): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState))\n#20 /opt/drupal/web/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'node_unipv_come...')\n#21 /opt/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(593): Drupal\Core\Form\FormValidator->validateForm('node_unipv_come...', Array, Object(Drupal\Core\Form\FormState))\n#22 /opt/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm('node_unipv_come...', Array, Object(Drupal\Core\Form\FormState))\n#23 /opt/drupal/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\node\NodeForm), Object(Drupal\Core\Form\FormState))\n#24 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))\n#25 /opt/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)\n#26 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()\n#27 /opt/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))\n#28 /opt/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)\n#29 /opt/drupal/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()\n#30 /opt/drupal/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)\n#31 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)\n#32 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)\n#33 /opt/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)\n#34 /opt/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)\n#35 /opt/drupal/vendor/asm89/stack-cors/src/Asm89/Stack/Cors.php(49): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)\n#36 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Asm89\Stack\Cors->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)\n#37 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)\n#38 /opt/drupal/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)\n#39 /opt/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)\n#40 /opt/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))\n#41 {main}, referer: http://localhost/node/36/edit Can someone help me in the configuration?

3
  • What was the error? Commented Jul 19 at 9:10
  • The error information belongs in the Question rather than in a comment.
    – mona lisa
    Commented Jul 21 at 17:58
  • You should get the stack trace also.
    – mona lisa
    Commented Jul 22 at 10:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.