Symfony2 FOSUserBundle在twig模板中显示expiresAt[英] Symfony2 FOSUserBundle Display expiresAt in twig template

本文是小编为大家收集整理的关于Symfony2 FOSUserBundle在twig模板中显示expiresAt的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我想在树枝上显示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 %}

注册日期非常好.

推荐答案

我在我的User实体中添加了一种方法

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

因为fosuserbundle模型用户没有getExpiresAt方法

本文地址:https://www.itbaoku.cn/post/2090837.html

问题描述

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.

推荐答案

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