Skip to content

Renamed precision option to scale #5005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions reference/forms/types/integer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ integers. By default, all non-integer values (e.g. 6.78) will round down (e.g. 6
| Rendered as | ``input`` ``number`` field |
+-------------+-----------------------------------------------------------------------+
| Options | - `grouping`_ |
| | - `precision`_ |
| | - `scale`_ |
| | - `rounding_mode`_ |
+-------------+-----------------------------------------------------------------------+
| Inherited | - `data`_ |
Expand All @@ -42,7 +42,7 @@ Field Options

.. include:: /reference/forms/types/options/grouping.rst.inc

.. include:: /reference/forms/types/options/precision.rst.inc
.. include:: /reference/forms/types/options/scale.rst.inc

rounding_mode
~~~~~~~~~~~~~
Expand Down
14 changes: 9 additions & 5 deletions reference/forms/types/money.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ how the input and output of the data is handled.
| Options | - `currency`_ |
| | - `divisor`_ |
| | - `grouping`_ |
| | - `precision`_ |
| | - `scale`_ |
+-------------+---------------------------------------------------------------------+
| Inherited | - `data`_ |
| options | - `disabled`_ |
Expand Down Expand Up @@ -73,14 +73,18 @@ be set back on your object.

.. include:: /reference/forms/types/options/grouping.rst.inc

precision
~~~~~~~~~
scale
~~~~~

.. versionadded:: 2.7
The ``scale`` option was introduced in Symfony 2.7. Prior to Symfony 2.7,
it was known as ``precision``.

**type**: ``integer`` **default**: ``2``

For some reason, if you need some precision other than 2 decimal places,
For some reason, if you need some scale other than 2 decimal places,
you can modify this value. You probably won't need to do this unless,
for example, you want to round to the nearest dollar (set the precision
for example, you want to round to the nearest dollar (set the scale
to ``0``).

Inherited Options
Expand Down
10 changes: 5 additions & 5 deletions reference/forms/types/number.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ number Field Type
=================

Renders an input text field and specializes in handling number input. This
type offers different options for the precision, rounding, and grouping that
you want to use for your number.
type offers different options for the scale, rounding and grouping that you
want to use for your number.

+-------------+----------------------------------------------------------------------+
| Rendered as | ``input`` ``text`` field |
+-------------+----------------------------------------------------------------------+
| Options | - `grouping`_ |
| | - `precision`_ |
| | - `scale`_ |
| | - `rounding_mode`_ |
+-------------+----------------------------------------------------------------------+
| Inherited | - `data`_ |
Expand All @@ -38,14 +38,14 @@ Field Options

.. include:: /reference/forms/types/options/grouping.rst.inc

.. include:: /reference/forms/types/options/precision.rst.inc
.. include:: /reference/forms/types/options/scale.rst.inc

rounding_mode
~~~~~~~~~~~~~

**type**: ``integer`` **default**: ``NumberToLocalizedStringTransformer::ROUND_HALFUP``

If a submitted number needs to be rounded (based on the ``precision``
If a submitted number needs to be rounded (based on the `scale`_
option), you have several configurable options for that rounding. Each
option is a constant on the :class:`Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer`:

Expand Down
9 changes: 0 additions & 9 deletions reference/forms/types/options/precision.rst.inc

This file was deleted.

13 changes: 13 additions & 0 deletions reference/forms/types/options/scale.rst.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
scale
~~~~~

.. versionadded:: 2.7
The ``scale`` option was introduced in Symfony 2.7. Prior to Symfony 2.7,
it was known as ``precision``.

**type**: ``integer`` **default**: Locale-specific (usually around ``3``)

This specifies how many decimals will be allowed until the field rounds
the submitted value (via ``rounding_mode``). For example, if ``scale`` is set
to ``2``, a submitted value of ``20.123`` will be rounded to, for example,
``20.12`` (depending on your `rounding_mode`_).
14 changes: 9 additions & 5 deletions reference/forms/types/percent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This field adds a percentage sign "``%``" after the input box.
+-------------+-----------------------------------------------------------------------+
| Rendered as | ``input`` ``text`` field |
+-------------+-----------------------------------------------------------------------+
| Options | - `precision`_ |
| Options | - `scale`_ |
| | - `type`_ |
+-------------+-----------------------------------------------------------------------+
| Inherited | - `data`_ |
Expand All @@ -39,13 +39,17 @@ This field adds a percentage sign "``%``" after the input box.
Field Options
-------------

precision
~~~~~~~~~
scale
~~~~~

.. versionadded:: 2.7
The ``scale`` option was introduced in Symfony 2.7. Prior to Symfony 2.7,
it was known as ``precision``.

**type**: ``integer`` **default**: ``0``

By default, the input numbers are rounded. To allow for more decimal
places, use this option.
By default, the input numbers are rounded. To allow for more decimal places,
use this option.

type
~~~~
Expand Down