Closed
Description
Symfony version(s) affected: 4.x.x
Description
Whenever we try to validate a bigint with IntegerType the number will be rounded with no warning
How to reproduce
- In your entity add a field of type bigint
/**
* @ORM\Column(name="original_transaction_id", type="bigint", nullable=true)
*/
private $originalTransactionId;
- define Form validation type:
<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
class CreateFormValidationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add("originalTransactionId", IntegerType::class, [
"required" => true,
"constraints" => [
new Assert\NotNull,
]
])
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
"csrf_protection" => false,
"data_class" => MyEntity::class,
]);
}
}
- While validating the field it will change the value from bigint to a rounded int
$receiptFormType = CreateFormValidationType::class;
$receiptForm = $this->formFactory->create($receiptFormType, $MyEntity, ['allow_extra_fields' => true]);
$receiptForm->submit($data, true);
Additional context
I'm using this version of symfony form "symfony/form": "^4.2"