Skip to content

Latest commit

 

History

History
134 lines (93 loc) · 5.56 KB

number.rst

File metadata and controls

134 lines (93 loc) · 5.56 KB

single: Forms; Fields; NumberType

NumberType Field

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

Rendered as input text field
Options
Overridden options
Inherited options
Parent type FormType </reference/forms/types/form>
Class Symfony\\Component\\Form\\Extension\\Core\\Type\\NumberType

Field Options

html5

type: boolean default: false

4.3

The html5 option was introduced in Symfony 4.3.

If set to true, the HTML input will be rendered as a native HTML5 type="number" form.

input

type: string default: number

4.3

The input option was introduced in Symfony 4.3.

The format of the input data - i.e. the format that the number is stored on your underlying object. Valid values are number and string. Setting this option to string can be useful if the underlying data is a string for precision reasons (for example, Doctrine uses strings for the decimal type).

scale

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).

Overridden Options

Inherited Options

These options inherit from the FormType </reference/forms/types/form>:

The default value is '' (the empty string).