gatsby-plugin-gravity-forms
Version:
A component to take GraphQl Gravity Forms query data and return a usable form.
13 lines (11 loc) • 384 B
JavaScript
/**
* Loop through object of errors passed back by Gravity Forms
* Set errors to the corrosponding input
*/
export const handleGravityFormsValidationErrors = (data, setError) => {
Object.keys(data).forEach(function(key) {
const id = key.replace('.', '_')
const fieldId = `input_${id}`
setError(fieldId, 'gf_validation', data[key])
})
}