Notice: Undefined index: field_MY_css in Drupal\field_css\Traits\CssTrait::itemPrefixes() (line 36 of modules/contrib/field_css/src/Traits/CssTrait.php).

Created on 14 May 2022, over 2 years ago
Updated 12 January 2024, 11 months ago

Problem/Motivation

Getting notices:

  • Notice: Undefined index: field_c4c_css in Drupal\field_css\Traits\CssTrait::itemPrefixes() (line 36 of modules/contrib/field_css/src/Traits/CssTrait.php).
    Drupal\field_css\Traits\CssTrait::itemPrefixes(Object, 'default') (Line: 20)
    field_css_entity_view_alter(Array, Object, Object) (Line: 539)
    Drupal\Core\Extension\ModuleHandler->alter('commerce_store_view', Array, Object, Object) (Line: 305)
    Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 239)
    Drupal\Core\Entity\EntityViewBuilder->build(Array)
    call_user_func_array(Array, Array) (Line: 101)
    Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 772)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 363)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
    Drupal\Core\Render\Renderer->render(Array, ) (Line: 241)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 564)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 242)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
    call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 163)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    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: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    require('/home/merlin/Code-Incubator/site-c4c-dev/web/index.php') (Line: 65)
    

  • Notice: Trying to access array offset on value of type null in Drupal\field_css\Traits\CssTrait::itemPrefixes() (line 36 of modules/contrib/field_css/src/Traits/CssTrait.php).
    Drupal\field_css\Traits\CssTrait::itemPrefixes(Object, 'default') (Line: 20)
    field_css_entity_view_alter(Array, Object, Object) (Line: 539)
    Drupal\Core\Extension\ModuleHandler->alter('commerce_store_view', Array, Object, Object) (Line: 305)
    Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 239)
    Drupal\Core\Entity\EntityViewBuilder->build(Array)
    call_user_func_array(Array, Array) (Line: 101)
    Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 772)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 363)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
    Drupal\Core\Render\Renderer->render(Array, ) (Line: 241)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 564)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 242)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
    call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 163)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    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: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    require('/home/merlin/Code-Incubator/site-c4c-dev/web/index.php') (Line: 65)
    

  • Steps to reproduce

    View a display mode that does not display the css field.

    Proposed resolution

    Add some "if".

    🐛 Bug report
    Status

    Fixed

    Version

    2.0

    Component

    Code

    Created by

    🇩🇪Germany geek-merlin Freiburg, Germany

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

    Comments & Activities

    Not all content is available!

    It's likely this issue predates Contrib.social: some issue and comment data are missing.

    Production build 0.71.5 2024