VIEWS : Undefined array key "formatted" for TEXT(Long)

Created on 28 March 2024, 9 months ago
Updated 4 April 2024, 9 months ago

Problem/Motivation

When you create a new custom field with TEXT(Long) and create a new content. In logs you can see following warning:

Warning: Undefined array key "formatted" in Drupal\custom_field\Plugin\CustomField\FieldFormatter\TextDefaultFormatter->formatValue() (line 26 of web\modules\contrib\custom_field\src\Plugin\CustomField\FieldFormatter\TextDefaultFormatter.php)
#0 web\core\includes\bootstrap.inc(164): _drupal_error_handler_real(2, 'Undefined array...', 'C:\\wamp64\\www\\d...', 26)
#1 web\modules\contrib\custom_field\src\Plugin\CustomField\FieldFormatter\TextDefaultFormatter.php(26): _drupal_error_handler(2, 'Undefined array...', 'C:\\wamp64\\www\\d...', 26)
#2 web\modules\contrib\custom_field\src\Plugin\Field\FieldFormatter\BaseFormatter.php(311): Drupal\custom_field\Plugin\CustomField\FieldFormatter\TextDefaultFormatter->formatValue(Array)
#3 web\modules\contrib\custom_field\src\Plugin\Field\FieldFormatter\CustomFormatter.php(45): Drupal\custom_field\Plugin\Field\FieldFormatter\BaseFormatter->getFormattedValues(Object(Drupal\custom_field\Plugin\Field\FieldType\CustomItem), 'en')
#4 web\modules\contrib\custom_field\src\Plugin\Field\FieldFormatter\BaseFormatter.php(206): Drupal\custom_field\Plugin\Field\FieldFormatter\CustomFormatter->viewValue(Object(Drupal\custom_field\Plugin\Field\FieldType\CustomItem))
#5 web\core\lib\Drupal\Core\Field\FormatterBase.php(91): Drupal\custom_field\Plugin\Field\FieldFormatter\BaseFormatter->viewElements(Object(Drupal\custom_field\Plugin\Field\FieldType\CustomItemList), 'en')
#6 web\core\lib\Drupal\Core\Entity\Entity\EntityViewDisplay.php(268): Drupal\Core\Field\FormatterBase->view(Object(Drupal\custom_field\Plugin\Field\FieldType\CustomItemList), 'en')
#7 web\core\lib\Drupal\Core\Entity\EntityViewBuilder.php(339): Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array)
#8 web\core\modules\node\src\NodeViewBuilder.php(24): Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'full')
#9 web\core\lib\Drupal\Core\Entity\EntityViewBuilder.php(281): Drupal\node\NodeViewBuilder->buildComponents(Array, Array, Array, 'full')
#10 web\core\lib\Drupal\Core\Entity\EntityViewBuilder.php(238): Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array)
#11 [internal function]: Drupal\Core\Entity\EntityViewBuilder->build(Array)
#12 web\core\lib\Drupal\Core\Security\DoTrustedCallbackTrait.php(111): call_user_func_array(Array, Array)
#13 web\core\lib\Drupal\Core\Render\Renderer.php(859): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
#14 web\core\lib\Drupal\Core\Render\Renderer.php(421): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
#15 web\core\lib\Drupal\Core\Render\Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
#16 web\core\lib\Drupal\Core\Render\MainContent\HtmlRenderer.php(238): Drupal\Core\Render\Renderer->render(Array, false)
#17 web\core\lib\Drupal\Core\Render\Renderer.php(627): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#18 web\core\lib\Drupal\Core\Render\MainContent\HtmlRenderer.php(239): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#19 web\core\lib\Drupal\Core\Render\MainContent\HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#20 web\core\lib\Drupal\Core\EventSubscriber\MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#21 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#22 web\core\lib\Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#23 vendor\symfony\http-kernel\HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
#24 vendor\symfony\http-kernel\HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#25 web\core\lib\Drupal\Core\StackMiddleware\Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 web\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 web\core\lib\Drupal\Core\StackMiddleware\ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 web\core\modules\big_pipe\src\StackMiddleware\ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 web\core\modules\page_cache\src\StackMiddleware\PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 web\core\modules\page_cache\src\StackMiddleware\PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 web\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 web\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 web\core\lib\Drupal\Core\StackMiddleware\AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#34 web\core\lib\Drupal\Core\StackMiddleware\StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#35 web\core\lib\Drupal\Core\DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#36 web\index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
๐Ÿ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

๐Ÿ‡ธ๐Ÿ‡ฐSlovakia coaston

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

Comments & Activities

  • Issue created by @coaston
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States apmsooner

    I believe several of these issues you are reporting may already be fixed in dev version. Can you test dev please and verify if the issue persists?

  • ๐Ÿ‡ธ๐Ÿ‡ฐSlovakia coaston

    I am unable to downloadn 3dev via composer, that is the reason why I used 3.0 beta2.
    However will try to download it manually and test.
    Tnx

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States apmsooner

    In the other issue you said you were using the 2.x version. 3.x version is only for Drupal core 10.2^. I'm confused with where you are finding these bugs and what version you are actually using.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States apmsooner

    If you need 2.x dev:

    composer require 'drupal/custom_field:2.0.x-dev@dev'

    If you need 3.x dev:

    composer require 'drupal/custom_field:3.0.x-dev@dev'

    If you are using ddev, lando, etc... locally than prefix those commands accordingly.

    You may need to set this in composer.json if you get warnings on installing a dev version: "minimum-stability": "dev"

  • ๐Ÿ‡ธ๐Ÿ‡ฐSlovakia coaston

    Thank you.

    Maybe you can help me with my problem. I am using wamp server and when I installed composer and use cmd with admin rights i am unable to run following cmd:

    composer require 'drupal/custom_field:^3.0@beta'

    It statted i need to get rid of ยด so i when i use:

    composer require drupal/custom_field:^3.0@beta
    I am getting error with path..

    So i found somewhere on google the way it works for me and it has to be the full adress like :

    composer require drupal/custom_field:^3.0.0-beta2

    The same for version 2.0.1 i need to use the following path:
    composer require drupal/custom_field:^2.0.1

    The same issue for all modules but for some I can download dev verzions because when I try yours like:

    composer require drupal/custom_field:2.0.x-dev@dev without "ยด" it does not work so i tried with

    composer require drupal/custom_field:2.0.x-dev which works for me in other cases (other modules) but does not for this module.

    To be honest I used Ludwig before so I am learning with composer and i am not sure why i have to remove "ยด" and have to update link for the direct address every time.
    It is because of CMD in windows?
    But when i tried with console on hosting server I had the same issue...

    So i am really confused why it does not work as stated in documentations.

    Will try "minimum-stability": "dev" to update JSON to see of this helps.

  • ๐Ÿ‡ธ๐Ÿ‡ฐSlovakia coaston

    Hello apmsooner,

    Looks like the first "formated" issue was resolved. So now when I save a content with long text there is no issue in log.
    However when you try the same with views there is still the same problem.

    1.Create a new view
    2.Add Custom field with long text
    3.Try preview it.
    4.Check logs.

    Even in 3-dev version I can see following :

    Warning: Undefined array key "formatted" in Drupal\custom_field\Plugin\CustomField\FieldFormatter\TextDefaultFormatter->formatValue() (line 28 of \web\modules\contrib\custom_field\src\Plugin\CustomField\FieldFormatter\TextDefaultFormatter.php)
    
  • Assigned to manish-31
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia manish-31
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia manish-31

    Hi @coaston

    I followed the steps mentioned by you to reproduce the warning but I don't see this warning.

    Steps followed -

    1. Added a text long custom field in a content type
    2. Added the field in a new view
    3. Previewed the view
    4. Checked the logs - nothing in the logs

    Could you please check again and maybe provide exact steps to replicate it?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States apmsooner

    I'm also unable to reproduce this issue. I just pushed some more updates to the dev branch last night that further solidifies the fields settings forms. I will be publishing a new 3.x release very soon now. Just trying to get the ajax issues resolved in unit tests.

  • Status changed to Fixed 9 months ago
  • Status changed to Fixed 9 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States apmsooner
Production build 0.71.5 2024