SYMFONY 3 - Could not load type "Tableless \ ModelBundle \ Form \ DatetimeType"

1

I'm learning SYMFONY 3.
The last steps I took before the error:

     to create crud with ORM Doctrine
     to create your route
     Sign in to 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 wrong? How can I overcome embarrassment?

    
asked by anonymous 22.04.2016 / 11:02

1 answer

1

Need to import .:
use Symfony \ Component \ Form \ Extension \ Core \ Type \ DateType; Change

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

for

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

source:
link

It looks 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'
       ));
   }
}
    
22.04.2016 / 11:34