Skip to content

Instantly share code, notes, and snippets.

@michaelrwiley
Created May 25, 2017 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelrwiley/a110f5384809b090b097d1af2b6c7660 to your computer and use it in GitHub Desktop.
Save michaelrwiley/a110f5384809b090b097d1af2b6c7660 to your computer and use it in GitHub Desktop.
/*
To be used as such:
import FormFunctions from 'form_funcs';
FormFunctions.handleControlRegistration... etc.
*/
module.exports = {
handleControlRegistration(obj, context) {
context.Apple = true;
if(!context.FromControlList) context.FromControlList = [];
context.FromControlList.push(obj);
},
isFormValid(context) {
let formIsValid = true;
for(let i = 0; i < context.FromControlList.length; i++){
let valid = context.FromControlList[i].ValidateFunction();
if (valid === false) formIsValid = false;
}
return formIsValid;
},
handleGetFormData(context) {
let postData = {};
for (let i = 0; i < context.FromControlList.length; i++) {
let value = context.FromControlList[i].GetValue();
postData[context.FromControlList[i].Name] = value;
}
return postData;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment