Aipo
Aipo

Reputation: 1985

Symfony 3 FormRegistry ->getType ('datetime')

When trying to load view, Symfony Profiler says:

Could not load type "datetime"

I use default builder:

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('name')
        ->add('dateCreated', 'datetime')
        ->add('dateModified', 'datetime')

    ;
}

How to create time fields and load view with no error?

Upvotes: 1

Views: 216

Answers (2)

bourvill
bourvill

Reputation: 160

In symfony 3.0

Replace

'datetime'

With

 \Symfony\Component\Form\Extension\Core\Type\DateTimeType::class

You can import the namespace

Upvotes: 1

Matteo
Matteo

Reputation: 39460

The fully qualified class name is required since Symfony 3.0:

$builder->add('dateCreated', DatetimeType::class);    
$builder->add('dateModified', DatetimeType::class);

Hope this help

Upvotes: 1

Related Questions