Using a period instead of a semicolon when displaying a decimal number

In db, the field is a decimal type and is stored as follows: 0.5

In Entity field

/** @ORM\Column(name="precio_x_ticket", type="decimal", scale=2) */ 

In FormType, the field is configured as follows

 ->add('precio_x_ticket','money', array( //'grouping' => true, 'currency' => false, 'label' => 'Precio por ticket', )) 

When saving from a form, I can save numbers, as in this format 0.5 or 0.5, but after saving the number always return this format 0.5, and I would like to show it as 0.5

My locale es

Any idea how to solve this problem using only symfony2.5?

0
source share
2 answers

Since I used {{ form_start(formulario) }} , I needed to use

{{ form_widget(formulario.precio_x_ticket, {'value': formulario.precio_x_ticket.vars.value|number_format(2, '.', ' ')}) }}

to show the value in the # format. ##.

+2
source

You can use number_format anywhere. You want to display the number in the user view. I would not suggest changing your locale or making other system changes, as this would create an unregistered and system dependent / configuration code.

0
source

All Articles