From 827b756d0c326a7e5257a30b6388ae82a44d5710 Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Tue, 7 Nov 2023 06:02:21 -0500 Subject: [PATCH] add single_text widget for all date types --- src/Doctrine/EntityDetails.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Doctrine/EntityDetails.php b/src/Doctrine/EntityDetails.php index 03fdc27bf..76b44c383 100644 --- a/src/Doctrine/EntityDetails.php +++ b/src/Doctrine/EntityDetails.php @@ -13,6 +13,8 @@ use Doctrine\Persistence\Mapping\ClassMetadata; use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Symfony\Bundle\MakerBundle\Tests\Doctrine\DoctrineHelperTest; +use Symfony\Component\Form\Extension\Core\Type\DateType; /** * @author Sadicov Vladimir @@ -61,6 +63,17 @@ public function getFormFields(): array $fieldsWithTypes[$field] = null; } + foreach ($this->metadata->fieldMappings as $fieldName => $fieldMapping) { + $propType = DoctrineHelper::getPropertyTypeForColumn($fieldMapping['type']); + if (($propType === '\\' . \DateTimeImmutable::class) || + ($propType === '\\' . \DateTimeInterface::class)) + { + $fieldsWithTypes[$fieldName] = [ + 'type' => null, + 'options_code' => "'widget' => 'single_text'" + ]; + } + } foreach ($this->metadata->associationMappings as $fieldName => $relation) { if (\Doctrine\ORM\Mapping\ClassMetadata::ONE_TO_MANY === $relation['type']) { continue;