Skip to content

Commit

Permalink
[Form] fixed decimal rounding in IntegerField
Browse files Browse the repository at this point in the history
Instead of rounding half-up (round to nearest neighbor) act as an integer cast
would and always round down (round towards zero).
  • Loading branch information
Brandon Turner authored and fabpot committed Sep 25, 2010
1 parent a305eb0 commit 9e84f45
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Symfony/Component/Form/IntegerField.php
Expand Up @@ -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>
Expand All @@ -24,6 +26,9 @@ protected function configure()
{
$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();
}

Expand Down

0 comments on commit 9e84f45

Please sign in to comment.