|
| 1 | +--- |
| 2 | +group: ui-components-guide |
| 3 | +title: FormDataProvider component |
| 4 | +contributor_name: Atwix |
| 5 | +contributor_link: https://www.atwix.com/ |
| 6 | +--- |
| 7 | + |
| 8 | +The FormDataProvider [UI component](https://glossary.magento.com/ui-component) is a data provider for the [Form]({{ page.baseurl }}/ui_comp_guide/components/ui-form.html) component. It stores form data in a specific format that is shared among all UI components in the scope of [Form]({{ page.baseurl }}/ui_comp_guide/components/ui-form.html) component and provides the functionality for submitting the data. |
| 9 | + |
| 10 | +## Configuration options |
| 11 | + |
| 12 | +| Option | Description | Type | Default Value | |
| 13 | +| --- | --- | --- | --- | |
| 14 | +| `class` | Path to the [PHP](https://glossary.magento.com/php) class responsible for the [backend](https://glossary.magento.com/backend) implementation of the component | String | `Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider` | |
| 15 | +| `component` | The path to the component's `.js` file, relative to RequireJS. | String | `Magento_Ui/js/form/provider` | |
| 16 | +| `clientConfig` | Configuration of the [FormClient]({{ site.mage2bloburl }}/{{page.guide_version}}/app/code/Magento/Ui/view/base/web/js/form/client.js) component. | Object | `urls: {save: '${ $.submit_url }',beforeSave: '${ $.validate_url }'}` | |
| 17 | +| `submit_url` | Path to controller that will process the form data submitting request. | String | `-` | |
| 18 | +| `validate_url` | Path to controller that will process the form data validation request. | String | `-` | |
| 19 | + |
| 20 | +## Sources files |
| 21 | + |
| 22 | +Extends [`UiElement`]({{ page.baseurl }}/ui_comp_guide/concepts/ui_comp_uielement_concept.html): |
| 23 | + |
| 24 | +- [app/code/Magento/Ui/view/base/web/js/form/provider.js]({{ site.mage2bloburl }}/{{page.guide_version}}/app/code/Magento/Ui/view/base/web/js/form/provider.js) |
| 25 | + |
| 26 | +## Examples |
| 27 | + |
| 28 | +### Integrate the FormDataProvider component with the Form component |
| 29 | + |
| 30 | +This is an example of how the FormDataProvider component integrates with the [Form]({{ page.baseurl }}/ui_comp_guide/components/ui-form.html) component: |
| 31 | + |
| 32 | +```xml |
| 33 | +<form> |
| 34 | + <dataSource name="sales_rule_form_data_source"> |
| 35 | + <argument name="data" xsi:type="array"> |
| 36 | + <item name="js_config" xsi:type="array"> |
| 37 | + <item name="component" xsi:type="string">Magento_Ui/js/form/provider</item> |
| 38 | + </item> |
| 39 | + </argument> |
| 40 | + <settings> |
| 41 | + <submitUrl path="path/to/submit_form_data_controller"/> |
| 42 | + <validateUrl path="path/to/validate_form_data_controller"/> |
| 43 | + </settings> |
| 44 | + </dataSource> |
| 45 | +</form> |
| 46 | +``` |
0 commit comments