Skip to content

Commit f0a0b55

Browse files
committed
minor #12534 MoneyType: explain why the divisor option is useful (alexislefebvre)
This PR was merged into the 3.4 branch. Discussion ---------- MoneyType: explain why the divisor option is useful I wanted to add an explanation about a reason to use the `divisor` option. Commits ------- 0bd5b65 MoneyType: explain why the divisor option is useful
2 parents 0b4c22d + 0bd5b65 commit f0a0b55

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

reference/forms/types/money.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ divisor
6161

6262
**type**: ``integer`` **default**: ``1``
6363

64-
If, for some reason, you need to divide your starting value by a number
64+
If you need to divide your starting value by a number
6565
before rendering it to the user, you can use the ``divisor`` option.
66-
For example::
66+
For example if you store prices as integer in order to avoid `rounding errors`_,
67+
you can transform values in cents automatically::
6768

6869
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
6970
// ...
@@ -139,3 +140,4 @@ money_pattern ``string`` The format to use to display the money, including the
139140
============= ========== ===============================================================
140141

141142
.. _`3 letter ISO 4217 code`: https://en.wikipedia.org/wiki/ISO_4217
143+
.. _`rounding errors`: https://0.30000000000000004.com/

0 commit comments

Comments
 (0)