Accesing model data in array

I'm trying to use {{ modelData()["user"].name() }} to acces a User instance's name, but Volt gets an unexpected -> in the template. The compiled template shows me that the result is (POST::getModelData()["user"])->name(), so... is there a way to avoid the parenthesis?



44.7k

Try `{{ modelData()["user"].name() }}



18.5k

Try `{{ modelData()["user"].name() }}

Ups, edited the code. That was what I have, not ->.



18.5k

Ok ok, I did a work around setting a var with the array's data:

{% set aux = modelData()["user"] %}

This way I can avoid the parenthesis, because aux is just a single object (thing, said in some form), but modelData()["user"] has to be englobed, because I'm trying to access something (name() method) in a subobject (modelData()["user"]).