Question

In my entity, they are two fields: the latitude and the longitude. There are declared as follows:

/**
 * @var decimal
 * @ORM\Column(name="lat", type="decimal", precision=18,scale=14, nullable=true)
 */
private $lat;    

/**
 * @var decimal
 * @ORM\Column(name="lng", type="decimal", precision=18,scale=14, nullable=true)
 */
private $lng; 

I created a form and I entred the latitude and the longitude. This worked well. The data I entred is: lat= 36.80610237001900, lng=10.17517220741000.

I checked in the data base and I find it as I entred (ie: lat= 36.80610237001900, lng=10.17517220741000)

But, when I wanted to edit the latitude and the longitude through the form, I got these values in the text inputs: lat= 36.806, lng=10.175.

The question is: how to make these text inputs display the exact values? How to specify the scale of the input texts? How to cancel rounding of decimals?

NB: This problem appreared after an update the bundles by the command:

php composer.phar update 

If I am well remembering, doctrine/orm has been updated!

This is a part of my composer.json file:

    "symfony/symfony": "2.3.*",
    "doctrine/orm": ">=2.2.3,<2.4-dev",
    "doctrine/doctrine-bundle": "1.2.*",

I you have any ideas, don't hesitate! Thanks,

Was it helpful?

Solution

I find the solution! When building the form, don't forget to specify the precision like this:

->add('lat','number', array('precision' => 14,'required' => false))
->add('lng','number', array('precision' => 14,'required' => false))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top