single: Forms; Fields; money
Renders an input text field and specializes in handling submitted "money" data.
This field type allows you to specify a currency, whose symbol is rendered next to the text field. There are also several other options for customizing how the input and output of the data is handled.
Rendered as | input text field |
Options | |
Inherited options | |
Parent type | form </reference/forms/types/form> |
Class | Symfony\\Component\\Form\\Extension\\Core\\Type\\MoneyType |
type: string
default: EUR
Specifies the currency that the money is being specified in. This determines the currency symbol that should be shown by the text box. Depending on the currency - the currency symbol may be shown before or after the input text field.
This can be any 3 letter ISO 4217 code. You can also set this to false to hide the currency symbol.
type: integer
default: 1
If, for some reason, you need to divide your starting value by a number before rendering it to the user, you can use the divisor
option. For example:
$builder->add('price', 'money', array(
'divisor' => 100,
));
In this case, if the price
field is set to 9900
, then the value 99
will actually be rendered to the user. When the user submits the value 99
, it will be multiplied by 100
and 9900
will ultimately be set back on your object.
type: integer
default: 2
For some reason, if you need some precision 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 to 0
).
These options inherit from the form </reference/forms/types/form>
type:
The default value is ''
(the empty string).
Variable | Type | Usage |
---|---|---|
money_pattern | string |
The format to use to display the money, including the currency. |