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
Post a Comment