SYMFONY 3 -> Could not load type "Tableless Modelbundle Form Datetimetype"

Asked

Viewed 62 times

1

I’m learning SYMFONY 3.
Last steps I made before the error.:

create crud with Doctrine ORM
create your route
Enter the post page

After loading "Create a new entry" gives the following error.:
Could not load type "Tableless Modelbundle Form Datetimetype"
500 Internal Server Error - Invalidargumentexception

Page "Tableless Modelbundle Form Posttype.php"

namespace Tableless\ModelBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class PostType extends AbstractType
{
   /**
    * @param FormBuilderInterface $builder
    * @param array $options
    */
   public function buildForm(FormBuilderInterface $builder, array $options)
   {
       $builder
           ->add('title')
           ->add('content')
           ->add('createdAt', 'datetime')
           ->add('updateAt', 'datetime')
       ;
   }

   /**
    * @param OptionsResolver $resolver
    */
   public function configureOptions(OptionsResolver $resolver)
   {
       $resolver->setDefaults(array(
           'data_class' => 'Tableless\ModelBundle\Entity\Post'
       ));
   }
}

What was done incorrectly?
How can I overcome embarrassment?

1 answer

1


It is necessary to import.:
use Symfony Component Form Extension Core Type Datetype;
Alter

->add('createdAt', 'datetime')
->add('updateAt', 'datetime')

for

->add('createdAt', DateType::class)
->add('updateAt', DateType::class)

source.:
https://github.com/symfony/symfony/issues/17510

Stayed like this.:

namespace Tableless\ModelBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\DateType;

class PostType extends AbstractType
{
   /**
    * @param FormBuilderInterface $builder
    * @param array $options
    */
   public function buildForm(FormBuilderInterface $builder, array $options)
   {
       $builder
           ->add('title')
           ->add('content')
           ->add('createdAt', DateType::class)
           ->add('updateAt', DateType::class)
       ;
   }

   /**
    * @param OptionsResolver $resolver
    */
   public function configureOptions(OptionsResolver $resolver)
   {
       $resolver->setDefaults(array(
           'data_class' => 'Tableless\ModelBundle\Entity\Post'
       ));
   }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.