Open andrelec1 opened 3 years ago
$builder ->add('date', DateTimeType::class, [ 'widget' => 'single_text', ]) ;
result => Could not find a transformer for any of these types (datetime, form)
Actualy a bypass by using a simple text input and appy a transformer on it :
->addModelTransformer(new CallbackTransformer( function ($datetimeObj) { if ($datetimeObj === null) { return ''; } return $datetimeObj->format('Y-m-d H:i:s'); }, function ($datetimeString) { return \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $datetimeString, new \DateTimeZone('UTC')); } ))
result => Could not find a transformer for any of these types (datetime, form)
Actualy a bypass by using a simple text input and appy a transformer on it :