2016-04-20 54 views
1

我想显示在我的树枝的expiresAt,但我有此错误:在树枝模板Symfony2的FOSUserBundle显示expiresAt

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

在我的树枝,我做了对:

{% 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 %} 

的registrationdate显示得非常好。

+3

在你的实体用户扩展的假设FOSUserBundle模型用户,因为在FOSUserBundle中没有这样的方法,所以您需要为您的实体添加一个方法到'getExpiresAt()'。 – geoB

+0

谢谢你的回答它的正确我在我的用户实体中添加了一个方法public function getExpiresAt(){ return $ this-> expiresAt; }因为FOSUserBundle模型用户没有getExpiresAt方法 –

回答

1

answer of geoB是正确

我在User实体添加方法

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

因为FOSUserBundle型号用户这么想的有getExpiresAt方法