[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:
Brandon Turner 2010-09-24 13:36:36 -05:00 committed by Fabien Potencier
parent a305eb063d
commit 9e84f450c2
1 changed files with 5 additions and 0 deletions

View File

@ -2,6 +2,8 @@
namespace Symfony\Component\Form;
use Symfony\Component\Form\ValueTransformer\NumberToLocalizedStringTransformer;
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
@ -24,6 +26,9 @@ class IntegerField extends NumberField
{
$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();
}