2016-04-20 80 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方法