 <p>The error that you showed is because Twig is trying to execute the <code>getLastname()</code> method in your object and it's not defined.</p> <p>The solution is the one provided by @qooplmao in a previous comment and use the <a href="http://twig.sensiolabs.org/doc/functions/attribute.html" rel="nofollow">attribute() function</a>:</p> <pre><code>{{ attribute(obj, 'getLastname' ~ suff) }} </code></pre>