Easy admin list modification

896 Views Asked by At

I don't get this guys!

At this moment I still have only one entity (User). I manage my users with the FOSUserBundle.

I want to modify the fields displayed in my list. Like this right?

config.yml

easy_admin:
    entities:
        Users:
            class: AppBundle\Entity\User
            list:
                fields:
                    - username
                    - email
                    - last_login

But I get this error when trying to do it;

An exception has been thrown during the rendering of a template ("Warning: mb_strlen() expects parameter 1 to be string, object given") in @EasyAdmin/default/field_text.html.twig at line 4.

I've added a __toString() method in my User entity but it still doesn't work;

User.php

public function __toString()
{
    return $this->getUsername();
}

I am pretty new to the whole Symfony thing, so can somebody please help me out?

1

There are 1 best solutions below

0
On

This issue is fixed and will probably be available with the next stable release.

In the meantime you can fix this by manually copy paste this 5 lines into EasyAdminTwigExtention.php at line 269.

try {
     $value = (string) $value;
    } catch (\Exception $e) {
         $value = '';
    }

Look here for the same question I asked on Git. And here where the code is modified.