1

I want to set the minimal date in input date

$builder->add('dateRdv', DateTimeType::class,['data'   => new \DateTime(),
                'attr'   => ['min' => new \DateTime()]])

Error is :

An exception has been thrown during the rendering of a template ("Catchable Fatal Error: Object of class DateTime could not be converted to string").

**

Khalil
  • 288
  • 3
  • 16

1 Answers1

4

You are using Datetime as a string, as the error said, just format it into a string:

$builder->add('dateRdv', DateTimeType::class,['data'   => new \DateTime(),
                'attr'   => ['min' => ( new \DateTime() )->format('Y-m-d H:i:s')]]);
Elanochecer
  • 600
  • 3
  • 8