Creates a FormData object and populate it with data from the the provided object.
Parameters:
Name | Type | Description |
---|---|---|
obj | object | The source of data to be used when populating FormData. |
rootName | string | The root name of the field for each data value. |
ignoreList | Array | Array of property names to be ignored when populating FormData. |
- Since
- 1.0.0
Returns:
Returns a FormData object, populated with data from the provided object.
- Type:
- FormData
Example
import { objectToFormData } from "@gravityforms/utils";
function Example() {
const obj = {
one: 1,
two: 2,
three: {
a: 'a',
b: 'b',
},
};
const output = objectToFormData( obj, 'data', [ 'data[one]' ] );
}