I face off this message on certains pages, somtimes relate to twig template part, sometimes to other things.
In watchdog:
User error : "2" is an invalid render array key dans Drupal\Core\Render\Element::children() (/home//www/pfdev/multid9/recommended-project/web/core/lib/Drupal/Core/Render/Element.php ligne 98)
#0 /home//www/pfdev/multid9/recommended-project/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real(256, '"2" is an inval...', '/home/provencef...', 98)
#1 [internal function]: _drupal_error_handler(256, '"2" is an inval...', '/home/provencef...', 98)
#2 /home//www/pfdev/multid9/recommended-project/web/core/lib/Drupal/Core/Render/Element.php(98): trigger_error('"2" is an inval...', 256)
#3 /home//www/pfdev/multid9/recommended-project/web/core/lib/Drupal/Core/Render/Renderer.php(404): Drupal\Core\Render\Element::children(Array, true)
#4 /home//www/pfdev/multid9/recommended-project/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, false)
#5 /home//www/pfdev/multid9/recommended-project/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render(Array)
#6 /home//www/pfdev/multid9/recommended-project/vendor/twig/twig/src/Environment.php(418) : eval()'d code(458): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
The othe rpost on this subject lead me to check my array sinto .theme like:
function starter_d9_2022_theme_suggestions_views_view_alter(array &$suggestions, array $variables) {
$suggestions[] = 'views_view__' . $variables['view']->id();
// If you want you can add a template suggestion for all views
// based on their ID:
$suggestions[] = sprintf('views_view__%s', $variables['view']->id());
// Or you can check the ID, add suggestions, do whatever you want
// ...
}
function starter_d9_2022_theme_suggestions_views_view(array $variables) {
return [
'views_view_display__' . $variables['view']->current_display,
// Suggestion pour chaque affichages de la vue
];
}
but no effect instead of a WSOD. So I have no clue to fix this. Do someone know ?
Thanks
EDIt: after advices, it appear this correction goes wrong in the IDE(VS Code). Because of comment ?
function starter_d9_2022_theme_suggestions_views_view(array $variables) {
//return [
'views_view_display__' . $variables['view']->current_display;
// Suggestion pour chaque affichages de la vue
//];
}