$ composer show sonata-project/*
sonata-project/admin-bundle 3.15.0 The missing Symfony Admin Generator
sonata-project/block-bundle 3.3.2 Symfony SonataBlockBundle
sonata-project/cache 1.0.7 Cache library
sonata-project/core-bundle 3.3.0 Symfony SonataCoreBundle
sonata-project/datagrid-bundle 2.2.1 Symfony SonataDatagridBundle
sonata-project/doctrine-extensions 1.0.2 Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.1.4 Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/easy-extends-bundle 2.1.10 Symfony SonataEasyExtendsBundle
sonata-project/exporter 1.7.1 Lightweight Exporter library
sonata-project/google-authenticator 1.0.2 Library to integrate Google Authenticator into a PHP project
sonata-project/user-bundle 3.2.3 Symfony SonataUserBundle
$ composer show symfony/*
symfony/assetic-bundle v2.8.1 Integrates Assetic into Symfony2
symfony/monolog-bundle v3.1.0 Symfony MonologBundle
symfony/polyfill-apcu v1.3.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu v1.3.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring v1.3.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php54 v1.3.0 Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions
symfony/polyfill-php55 v1.3.0 Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions
symfony/polyfill-php56 v1.3.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70 v1.3.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util v1.3.0 Symfony utilities for portability of PHP codes
symfony/security-acl v3.0.0 Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.5.4 Symfony SwiftmailerBundle
symfony/symfony v2.8.18 The Symfony PHP framework
$ php -v
PHP 7.1.1 (cli) (built: Feb 13 2017 10:05:49) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.1, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans
Unable to render Date field in list views
// use Symfony\Component\Form\Extension\Core\Type\DateType;
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->add(
'date',
DateType::class,
array(
'label' => 'Data',
'format' => 'd/m/Y',
'editable' => true,
)
)
// (...)

Catchable Fatal Error: Object of class DateTime could not be converted to string
can you please check if reverting this change #4415 fixes your problem?
@OskarStark still fails
and if you remove the editable option?
I've tried it and it doesn't work!
Can you bisect it down to a particular commit?
I've discovered that if I change date type in string it works, but in class name doesn't works.
->add(
'date',
'date',
array(
'label' => 'Data',
'format' => 'd/m/Y',
'editable' => false,
)
)
That's very weird... What about the bisect?
The ListMapper and ShowMapper (thus ListBuilder and ShowBuilder) accept simple strings (eg. date, text, etc...) for type and not FormType classes. That is why date work, but DateType::class does not, because when the class is given, the type falls back to text, and the exception is thrown.
The doc clearly shows that these types are supported out-of-the-box: https://sonata-project.org/bundles/admin/3-x/doc/reference/action_list.html#available-types-and-associated-options
Also this line is wrong: https://github.com/sonata-project/SonataAdminBundle/blob/3.x/Resources/views/CRUD/base_list_field.html.twig#L51
It should be: {% if field_description.type == 'date' and value is not empty %}
Can you make a PR
It should be: {% if field_description.type == 'date' and value is not empty %}
good catch @fracsi 馃憤
Most helpful comment
The
ListMapperandShowMapper(thusListBuilderandShowBuilder) accept simple strings (eg. date, text, etc...) for type and notFormTypeclasses. That is whydatework, butDateType::classdoes not, because when the class is given, the type falls back to text, and the exception is thrown.The doc clearly shows that these types are supported out-of-the-box: https://sonata-project.org/bundles/admin/3-x/doc/reference/action_list.html#available-types-and-associated-options
Also this line is wrong: https://github.com/sonata-project/SonataAdminBundle/blob/3.x/Resources/views/CRUD/base_list_field.html.twig#L51
It should be:
{% if field_description.type == 'date' and value is not empty %}