Skip to content

Commit 0bd5b65

Browse files
MoneyType: explain why the divisor option is useful
1 parent e18250e commit 0bd5b65

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)