Creates a FormData object and populate it with data from the the provided object.

Parameters:
NameTypeDescription
objobject

The source of data to be used when populating FormData.

rootNamestring

The root name of the field for each data value.

ignoreListArray

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]' ] );
}