How to set decimal precision and scale within a symfony2 object? I defined latitude in longitude fields using the decimal data type in my entity as follows:
/** * @ORM\Column(type="decimal", precision="10", scale="6", nullable=true) */ protected $latitude;
When saving a new object, it saves the decimal value correctly (I can see 52.406374 in phpMyAdmin). However, when the editing form is displayed, the number is rounded to 52,406 , and after updating it is stored in mysql as 52.406000. Maybe something is wrong with my Doctrine configuration, but I don't know what.
Why is latitude and longitude rounded?
Found a solution:
The Symfony Form component displays the decimal form field as type = "text". Using:
->add('latitude', 'number', array( 'precision' => 6, ))
It is displayed correctly. The thread from the comment does not describe my problem. I think they have already fixed the error with precision "convert to float". When I showed the latitude in the branch template, it showed the correct (not rounded) value.
source share