How to create a number field that accepts numbers with comma or period in symfony 2

Viewed 5476

I have an application with a decimal field like:

/**
 * @var decimal $amount
 *
 * @ORM\Column(name="amount", type="decimal", scale="2")
 */
private $amount;

I want that the form to accept numbers with a format like "3,4" or "3.4".

If I enter "3.4" the application save in the database "3.4", if I enter "3,4" the application saves in the database "34" (yes, without comma and without showing validation error!).

(This is a known symfony bug: https://github.com/symfony/symfony/issues/2059 )

So, how can i accept numbers with commas as well as decimal points?

(I already tried to substitute commas with dot in a DataTrasformer, but DataTransformer takes the number already normalized.)

2 Answers
Related