-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathVueForm.js
More file actions
31 lines (26 loc) · 816 Bytes
/
Copy pathVueForm.js
File metadata and controls
31 lines (26 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { h } from "vue";
import { getComponent } from "./ComponentTypes";
import { useLeadStore } from "../stores/LeadStore";
const VueForm = (props) => {
// Setup empty store for form data
const store = useLeadStore();
props.formConfig.forEach((field) => {
switch (field.type) {
case "checkbox":
return (store.formData[field.name] = []);
case "radio":
return (store.formData[field.name] = "");
case "information":
break;
default:
return (store.formData[field.name] = "");
}
});
const formFields = props.formConfig.map((field) => {
let component = getComponent(field.type);
return { ...field, component };
});
// return the render function
return h(getComponent("formTemplate"), { formFields });
};
export default VueForm;