From 827b756d0c326a7e5257a30b6388ae82a44d5710 Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Tue, 7 Nov 2023 06:02:21 -0500 Subject: [PATCH 1/2] 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; From 6eb66ca7f60b63842802b50a4b8b4f40a03d2766 Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Tue, 7 Nov 2023 06:12:43 -0500 Subject: [PATCH 2/2] run php-cs-fixer --- src/Doctrine/EntityDetails.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Doctrine/EntityDetails.php b/src/Doctrine/EntityDetails.php index 76b44c383..dfd46ba25 100644 --- a/src/Doctrine/EntityDetails.php +++ b/src/Doctrine/EntityDetails.php @@ -13,8 +13,6 @@ 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 @@ -65,12 +63,11 @@ public function getFormFields(): array foreach ($this->metadata->fieldMappings as $fieldName => $fieldMapping) { $propType = DoctrineHelper::getPropertyTypeForColumn($fieldMapping['type']); - if (($propType === '\\' . \DateTimeImmutable::class) || - ($propType === '\\' . \DateTimeInterface::class)) - { + if (($propType === '\\'.\DateTimeImmutable::class) + || ($propType === '\\'.\DateTimeInterface::class)) { $fieldsWithTypes[$fieldName] = [ 'type' => null, - 'options_code' => "'widget' => 'single_text'" + 'options_code' => "'widget' => 'single_text'", ]; } }