I want to print "your_variable" (array) in my twig template, but i have errors.
I have .theme in my theme :
function MYTHEME_preprocess_views_view_fields(&$vars) {
$tempstore = \Drupal::service('user.private_tempstore')->get('evenementrimouski');
$some_data = $tempstore->get('nid');
$vars['your_variable'][] = array(3,4,5,6);
}
My "views-view-field" twig :
{% for value in your_variable %}
{{ value }}
{% endfor %}
The code work but i have errors :
User error: "0" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of core/lib/Drupal/Core/Render/Element.php).
User error: "1" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of core/lib/Drupal/Core/Render/Element.php).
Someone have idea to resolve this problem ?
I use Drupal 8
$vars['your_variable'] = array(3,4,5,6);
? You are looping over your_variable that is an array containing your array(3,4,5,6)