How to display float in Sonata admin bundle

720 views Asked by At

I've this code in entity

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

in amdin class

protected function configureFormFields(FormMapper $formMapper)
{
    $formMapper
        ->add('lng') 
        ...
}

It saves in normal precision (36.747148), but shows only 3 digits after dot (36.747). When I specify the type text it looks better but becomes required.
This works

        ->add('lng', 'text', ['required' => false])

is it the best/right solution? or do I need to change type decimal for something else?

1

There are 1 answers

1
l13 On

You can solve the problem with required like this:

    $form->add('lng', null, array(
        'required' => false
    ));