symfony - Show decimal percent type field -


i'm trying show form has percent type field can show values 3.03% exemple. seems rounding integers, e.g 3% in case.

entity field :

    /**      * @var float      * @orm\column(type="float")      */     private $penaltyrate; 

form builder :

... ->add('penaltyrate', percenttype::class, ['label' => 'create.form.penalty']) 

is limitation of percenttype , should use type , add manually '%' indicator ?

edit

for future googler, while @emanuel oster right pointing official symfony documentation, wasn't obvious me first time read here example if want allow 2 decimals :

form builder :

    ...     ->add('penaltyrate', percenttype::class, [       'label' => 'create.form.penalty',       'scale' => 2     ]) 

from symfony documentation:

scale

type: integer default: 0

by default, input numbers rounded. allow more decimal places, use option.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -