For situation where the entire form schema is created from a db record, one would pass the Schema as a JSON Object.
The problem with this is that the schema.fields.validator key expects a function and not a string.
{
"type": "input",
"inputType": "email",
"label": "E-mail",
"model": "email",
"placeholder": "User's e-mail address",
"validator": "VueFormGenerator.validators.email"
}
Is there a workaround so that the VFM validator can eval(thePassedString)?
Great contribution BTW, and thank you.
Actually this was implemented in the last release
https://github.com/icebob/vue-form-generator/releases
This is a shorthand for VueFormGenerator.validators.string. It can be an Array of Strings too.
You have to make sure these validators are declared and present in the window object.
In this case VueFormGenerator must be assigned to the window object window.VueFormGenerator=VueFormGenerator
Thank you!, works great!
It there s simular workaround for onSubmit in the submit button types?
( https://icebob.gitbooks.io/vueformgenerator/content/fields/submit.html )
... So I can pass a string of the function I want to call "onSubmit" : "mySubmitHandler"
Sorry, but I don't want to change every functions in vfg to handle string function names. You can solve it with a custom function in your project too.
new Vue({
data() {
return {
model: {...}
schema: convertStringFuncNames(mySchema)
}
}
});
function convertStringFuncNames(schema) {
....
}
Most helpful comment
Actually this was implemented in the last release
https://github.com/icebob/vue-form-generator/releases
This is a shorthand for
VueFormGenerator.validators.string. It can be an Array of Strings too.You have to make sure these validators are declared and present in the
windowobject.In this case
VueFormGeneratormust be assigned to the window objectwindow.VueFormGenerator=VueFormGenerator