[{"data":1,"prerenderedAt":32},["ShallowReactive",2],{"$falmu7msOYMWkAlhnZF8f3EE0GIoRjMsiGhZH4wkybJU":3,"$fSvdVheEo1K66OxuEFHBf6-ICl-S8UB5MuBPE_F2FU6k":23},{"content":4,"package":5,"version":22},"# Form\n\nThe MoneyBundle provides support for forms using a `Money` instance as a data object by providing an alternative `MoneyType` form type for the [Symfony Form component](https:\u002F\u002Fsymfony.com\u002Fdoc\u002Fcurrent\u002Fcomponents\u002Fform.html).\n\nWith the Form component installed, the form type will automatically be registered to your application and available for use in your form classes.\n\nNote, this form type uses the same block prefix as the native `MoneyType` provided by the Form component; this allows the form type provided by this bundle to act as a drop-in replacement from a templating perspective.\n\n```php\n\u003C?php\n\nnamespace App\\Form;\n\nuse BabDev\\MoneyBundle\\Form\\Type\\MoneyType;\nuse Symfony\\Component\\Form\\AbstractType;\nuse Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType;\nuse Symfony\\Component\\Form\\FormBuilderInterface;\n\nfinal class ProductForm extends AbstractType\n{\n    public function buildForm(FormBuilderInterface $builder, array $options): void\n    {\n        $builder\n            ->add(\n                'name',\n                TextType::class,\n                [\n                    'label' => 'app.form.label.product_name',\n                ]\n            )\n            ->add(\n                'price',\n                MoneyType::class,\n                [\n                    'label' => 'app.form.label.price',\n                ]\n            )\n        ;\n    }\n}\n```\n\nYou can also use the \u003Ca href=\"\u002Fopen-source\u002Fpackages\u002Fmoneybundle\u002Fdocs\u002F1.x\u002Fvalidator\">validator integration\u003C\u002Fa> to define constraints on your form types.\n\n```php\n\u003C?php\n\nnamespace App\\Form;\n\nuse BabDev\\MoneyBundle\\Form\\Type\\MoneyType;\nuse BabDev\\MoneyBundle\\Validator\\Constraints\\MoneyGreaterThanOrEqual;use Money\\Currency;use Money\\Money;use Symfony\\Component\\Form\\AbstractType;\nuse Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType;\nuse Symfony\\Component\\Form\\FormBuilderInterface;\n\nfinal class ProductForm extends AbstractType\n{\n    public function buildForm(FormBuilderInterface $builder, array $options): void\n    {\n        $builder\n            ->add(\n                'name',\n                TextType::class,\n                [\n                    'label' => 'app.form.label.product_name',\n                ]\n            )\n            ->add(\n                'price',\n                MoneyType::class,\n                [\n                    'label' => 'app.form.label.price',\n                    'currency' => new Currency('EUR'),\n                    'constraints' => [\n                        new MoneyGreaterThanOrEqual(Money::EUR(0)),\n                    ]\n                ]\n            )\n        ;\n    }\n}\n```\n\n## Options\n\nThe `MoneyType` form type largely accepts the same options as the form type from the Form component:\n\n- `currency` - Specifies the currency that the money is being specified in. Unlike the Form component, this must be provided as a `Money\\Currency` instance instead of a string. If not specified, the default currency from the `babdev_money.default_currency` configuration node is used.\n- `grouping` - This value is used internally as the `NumberFormatter::GROUPING_USED` value when using PHP's `NumberFormatter` class. This should be a boolean value and defaults to false. Note, this option cannot be used with the `html5` option.\n- `rounding_mode` - If a submitted number needs to be rounded (based on the `scale` option), you have several configurable options for that rounding. This should be one of the `NumberFormatter::ROUNDING_*` constants and defaults to `NumberFormatter::ROUND_HALFUP`.\n- `html5` - If set to true, the HTML input will be rendered as a native HTML5 number input. This should be a boolean value and defaults to false.\n- `scale` - If, for some reason, you need some scale other than 2 decimal places, you can modify this value. This should be an integer and defaults to 2.\n",{"name":6,"slug":7,"description":8,"github":9,"packagistName":11,"packageType":12,"hasDocumentation":13,"supported":13,"visible":13,"versions":14},"MoneyBundle","moneybundle","Integrates the Money for PHP library into Symfony applications",{"owner":10,"repo":6},"BabDev","babdev\u002Fmoney-bundle","symfony-bundle",true,[15,17,19],{"version":16,"released":13},"3.x",{"version":18,"released":13},"2.x",{"version":20,"released":13,"endOfSupport":21},"1.x","2025-11-30T23:59:59.999Z",{"version":20,"released":13,"endOfSupport":21},{"content":24,"package":25,"version":31},"- [Introduction](\u002Fopen-source\u002Fpackages\u002Fmoneybundle\u002Fdocs\u002F1.x\u002Fintro)\n- [Installation & Setup](\u002Fopen-source\u002Fpackages\u002Fmoneybundle\u002Fdocs\u002F1.x\u002Finstallation)\n- [Default Configuration](\u002Fopen-source\u002Fpackages\u002Fmoneybundle\u002Fdocs\u002F1.x\u002Fdefault-configuration)\n- [Doctrine](\u002Fopen-source\u002Fpackages\u002Fmoneybundle\u002Fdocs\u002F1.x\u002Fdoctrine)\n- [Form](\u002Fopen-source\u002Fpackages\u002Fmoneybundle\u002Fdocs\u002F1.x\u002Fform)\n- [Serializer](\u002Fopen-source\u002Fpackages\u002Fmoneybundle\u002Fdocs\u002F1.x\u002Fserializer)\n- [Twig](\u002Fopen-source\u002Fpackages\u002Fmoneybundle\u002Fdocs\u002F1.x\u002Ftwig)\n- [Validator](\u002Fopen-source\u002Fpackages\u002Fmoneybundle\u002Fdocs\u002F1.x\u002Fvalidator)\n- [Configuring The Bundle](\u002Fopen-source\u002Fpackages\u002Fmoneybundle\u002Fdocs\u002F1.x\u002Fconfiguring-the-bundle)\n",{"name":6,"slug":7,"description":8,"github":26,"packagistName":11,"packageType":12,"hasDocumentation":13,"supported":13,"visible":13,"versions":27},{"owner":10,"repo":6},[28,29,30],{"version":16,"released":13},{"version":18,"released":13},{"version":20,"released":13,"endOfSupport":21},{"version":20,"released":13,"endOfSupport":21},1779706356816]