[Form] fixed decimal rounding in IntegerField
Instead of rounding half-up (round to nearest neighbor) act as an integer cast would and always round down (round towards zero).
This commit is contained in:
parent
a305eb063d
commit
9e84f450c2
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form;
|
namespace Symfony\Component\Form;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\ValueTransformer\NumberToLocalizedStringTransformer;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the symfony package.
|
* This file is part of the symfony package.
|
||||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||||
@ -24,6 +26,9 @@ class IntegerField extends NumberField
|
|||||||
{
|
{
|
||||||
$this->addOption('precision', 0);
|
$this->addOption('precision', 0);
|
||||||
|
|
||||||
|
// Integer cast rounds towards 0, so do the same when displaying fractions
|
||||||
|
$this->addOption('rounding-mode', NumberToLocalizedStringTransformer::ROUND_DOWN);
|
||||||
|
|
||||||
parent::configure();
|
parent::configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user