Context:
I create a project with symfony 3. My database have one table with a field datetime
With this commands I create a simple CRUD application for one table
php bin/console doctrine:mapping:import --force adminBundle xml
php bin/console doctrine:mapping:convert annotation ./src
php bin/console doctrine:generate:entities adminBundle
php bin/console generate:doctrine:crud
Error:
So my crud is done but when I edit one row throw an error
Could not load type "datetime" 500 Internal Server Error - InvalidArgumentException
Stack Trace
in vendor/symfony/symfony/src/Symfony/Component/Form/FormRegistry.php at line 87
I think that could not load type “datetme”, I try register my form in the section services of my services.yml, but I don't know How to do it? for the type datetime.
Any idea? thanks in advance.
Seems like a bug in the CRUD generator. It uses a type alias instead of the fully qualified class name:
$builder->add('fieldName', 'textarea');
The fully qualified class name is required since Symfony 3.0:
$builder->add('fieldName', DateTimeType::class);
Please check the generated form type.
Sergey, thanks for pointing that out. I'm not sure why, but specifying the fully qualified class name didn't resolve the issue on my end. Removing the datetime alias all together did.
Changed:
$builder
->add('name')
->add('time', 'datetime')
->add('location')
;
To:
$builder
->add('name')
->add('time')
->add('location')
;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With