How do I set the decimal precision and scale within the symfony2 entity? I've defined latitude in longitude fields using decimal data type in my entity like this:
/**
* @ORM\Column(type="decimal", precision="10", scale="6", nullable=true)
*/
protected $latitude;
When persisting new object it saves decimal correctly (I can see 52.406374 in phpMyAdmin). However when displaying edit form the number is rounded to 52,406 and after updating it is stored in mysql as 52.406000. Probably something is wrong with my Doctrine configuration, but I don't know what.
Why is the latitude and longitude getting rounded?
Found a solution:
Symfony's Form component renders decimal form field as type="text". When using:
->add('latitude', 'number', array(
'precision' => 6,
))
It is rendered properly. The thread from comment doesn't describe my problem. I guess they have already fixed bug with 'convert to float' precision. When I was displaying latitude in twig template it was showing proper (not rounded) value.