Search code examples
crudsymfony5easyadmin

EasyAdmin 3 Object of class DateTime could not be converted to string


I'm having a problem with easy admin 3. I followed the instructions of the symfony doc but I end up with this error: Object of class DateTime could not be converted to string when rendering the admin.

Thank you for you help !

class ArticleCrudController extends AbstractCrudController

{

/**
 * @return string
 */
public static function getEntityFqcn(): string
{
    return Article::class;
}

/**
 * @param Crud $crud
 * @return Crud
 */
public function configureCrud(Crud $crud): Crud
{
    return $crud
        ->setDateFormat('d/m/Y')
        // ...
        ;
}

}


Solution

  • In your "Article" entity you have a DateTime property. You need to implement method configureFields and return an DateTimeField. I don't know if it's the good way but it will fix your error.