Hello,
On a D9.5.5 + PHP 8.1.6 + v2.0.2 I get this warning:
User error: "0" is an invalid render array key in Drupal\Core\Render\Element::children() (line 98 of core/lib/Drupal/Core/Render/Element.php).
Drupal\Core\Render\Element::children(Array, 1) (Line: 404)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 456)
__TwigTemplate_c59cc24182b22b3f24b906e1d28be51c->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('themes/custom/starter-d9-2022/templates/nodes/node--page-lycee.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('node', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 243)
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)
This line in the template is for:
<span {{ telephone_attribute.addClass(telephone_classes) }}>
<strong> >>> {{ content.field_telephone_lycee|field_label }}</strong>
{{ ':' | raw}}
{{ content.field_telephone_lycee.0 }}
</span>
What can I do to fix this ?
Thanks
Comments
Comment #2
aiphesComment #3
sumit-k commentedTrie to replicate this issue with some other field, but didn't get it.
IMO To resolve this issue, you can try the following:
Check the structure of content.field_telephone_lycee to ensure it is an array and contains the expected data. You can use kint() or var_dump() to inspect the content variable and ensure it has the correct structure.
If content.field_telephone_lycee is a render array, you should use the children function to access the child elements.
I think content.field_telephone_lycee itself is rendered directly without using an index.
Comment #4
sumit-k commentedComment #5
aiphesOk will do that and do feedback. Thanks for your advice.
Comment #6
aiphesWith:
Result is:
Comment #7
aiphesNow the line change:
{% include directory ~ '/includes/regions_inc/inc_region_zone_3.html.twig' %}and my include is :
Comment #8
grevil commentedIs this still a problem in latest dev?