Unable to transform value for property path : Expected a \DateTime or \DateTimeInterface Unable to transform value for property path : Expected a \DateTime or \DateTimeInterface symfony symfony

Unable to transform value for property path : Expected a \DateTime or \DateTimeInterface


If you use Symfony forms you don't have to retrieve data from request "manually". The only thing you should do is to handle request:

$event = new Exvent();$form = $this->createForm(EventCreateFormType::class, $event);$form->handleRequest($request);

Handle request just binds data from request with entity properties. It takes value from form array, looks what type the property should be and converts it into appropriate format.

If you want to do that manually (then you don't have to create form - it's just useless) you should do something like this:

$startTime = new \DateTime($submittedForm['startTime']);$endTime = new DateTime($submittedForm['endTime']);

If, as you said, startTime and endTimes are array you have to build datetime string from those arrays before put them into DateTime constructor.

Then startTime and endTime will be type of DateTime.