Hello: I've scoured through a number of documents on the Drupal site and twig documentation and am stuck. I am getting the error:
User error: "foo" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of core\lib\Drupal\Core\Render\Element.php). User error: "bar" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of core\lib\Drupal\Core\Render\Element.php).
I am trying to pass an array into the twig template variable:
$array = array(
"foo" => "bar",
"bar" => "foo",
);
$element = array(
'#theme' => 'event_formatter',
'#events_result' => $array,
);
And the configuration in the .module file looks like:
return array(
'event_formatter' => array(
'variables' => array('events_result' => []),
'template' => 'event-formatter',
),
Passing a string variable seems fine.
Thanks!