Skip to content

Commit

Permalink
add single_text widget for all date types
Browse files Browse the repository at this point in the history
  • Loading branch information
tacman authored and jrushlow committed Feb 27, 2024
1 parent 11a9d31 commit 827b756
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Doctrine/EntityDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sadikoff@gmail.com>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 827b756

Please # to comment.