Get the values of form inputs as one collective object
npm install @degjs/form-mapperA utility to take in an element or array of elements and return an object consisting of their values
If you are already using NPM for your project, you can install formMapper with the following command:
```
$ npm install @degjs/form-mapper
import { getValues } from "@degjs/form-mapper";
.
.
.
const formData = getValues(formEl);
`$3
`
import formMapper from "@degjs/form-mapper";
.
.
.
const formData = formMapper.getValues(formEl);
`DefaultElementSelectors
The options represent the default selector names for various input elements. Can be replaced with a string of any selectors that querySelectAll and matches supports.Default:
input, select, textarea
Example override: .js-input, .js-checkbox-input, select[multiple], textareaMethods
$3
The getValues method returns an object with key value pairs being { inputName: inputValue }#### input
Type:
Element | Element[]
The container element, input element or array of elements to get values from.#### opts
Type:
Object
Default: {elementSelectors: defaultElementSelectors, shouldStringify: false}
An object to override the default settings. shouldStringify declares if the returned value should be a string representation of an object or just the object.$3
The getInputElements method returns an array of input elements as found by the default selectors.#### formEl
Type:
Element
The form element to extract inputs from.#### selectorSettings
Type:
String
Default: defaultElementSelectors`+ matches: Documentation | Polyfill
As of Febrary 2018, matches is supported in IE9 and up.
To support legacy browsers, you'll need to include polyfills for the above APIs.