Skip to content
Advertisement

Impossible to access an attribute on a string variable

In my controller i just pass some users on my twig view. Here is my function :

JavaScript

And this is my twig view where i want to display some information on a html table :

JavaScript

And i got this error : Impossible to access an attribute (“name”) on a string variable (” “). for this line :

JavaScript

Thanks for help!

And here is my User Entity

JavaScript

Advertisement

Answer

If you are using objects there is no need to set default value to string. Set it to null and check wether an user was found

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement