Symfony2 FOSUserBundle Display expiresAt in twig template

自作多情 提交于 2019-12-12 22:26:17

问题


I want to display the expiresAt in my twig but i have this error :

 Method "expiresat" for object "AuthenticationBundle\Entity\User" does not exist in AdminNCBundle:NC:list_clients.html.twig at line 43 

in my twig i have done a for :

   {% for client in clients %}
        <tr>
            <td>{{ client.firstname }} {{ client.lastname }}</td>
            <td>{{ client.telephone }}</td>
            <td>{{ client.registrationdate|date('Y-m-d H:i:s') }}</td>
            <td>{{ client.expiresat|date('Y-m-d H:i:s') }}</td>
            <td>{{ client.duration }}</td>
        </tr>
   {% endfor %}

the registrationdate displayed very well.


回答1:


the answer of geoB is correct

i added a method in my User entity

public function getExpiresAt() { 
    return $this->expiresAt; 
} 

because FOSUserBundle Model User dosen't has a getExpiresAt method



来源:https://stackoverflow.com/questions/36755231/symfony2-fosuserbundle-display-expiresat-in-twig-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!