From 1ebbd6e683a600257101472d7ea5b08774ec8448 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 26 Nov 2019 19:32:24 +0000 Subject: [PATCH] --- ayanova/src/api/gzform.js | 31 +++++++++++-------- .../src/components/custom-fields-control.vue | 7 +---- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ayanova/src/api/gzform.js b/ayanova/src/api/gzform.js index a7a8e175..46200f8c 100644 --- a/ayanova/src/api/gzform.js +++ b/ayanova/src/api/gzform.js @@ -348,27 +348,32 @@ export default { }, /////////////////////////////// // CUSTOMFIELDS + // For now the only rule is that they can be required or not // - customFieldsCheck(vm, ref, subvm, fieldName) { + customFieldsCheck(vm, templateItem, subvm, fieldName) { + +//templateItem sample +// dataKey: "c2" +// fld: "WidgetCustom2" +// hide: "false" +// required: "true" +// type: "text" + if (vm.formState.loading) { return false; } - if (window.$gz.errorHandler.devMode()) { - //make sure there is a customFields control in the refs to work with - //this is to ensure naming is correct mostly - if (!window.$gz._.has(vm.$refs, "customFields")) { - throw "DEV ERROR gzform::customFieldsCheck() -> vm.$refs.customFields is missing. Is it named correctly?"; - } + + if(!templateItem.required){ + return false; } -debugger; -var value=subvm.GetValueForField(ref); - var ctrl= getControl(vm,"customFields"); -var cdata = getControlValue(ctrl); + var value=subvm.GetValueForField(templateItem.dataKey); + if(!isEmpty(value)){ + return false; + } - -//TESTING: assume it's always a broken rule just to test if the rules will display properly + //It's empty and it's required so return error // "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}", var err = window.$gz.locale.get("ErrorRequiredFieldEmpty"); diff --git a/ayanova/src/components/custom-fields-control.vue b/ayanova/src/components/custom-fields-control.vue index bcdfaebf..342e0eef 100644 --- a/ayanova/src/components/custom-fields-control.vue +++ b/ayanova/src/components/custom-fields-control.vue @@ -54,12 +54,7 @@ :ref="item.fld" :error-messages="form().serverErrors(parentVM, item.fld)" :rules="[ - form().customFieldsCheck( - parentVM, - item.dataKey, - _self, - lt(item.fld) - ) + form().customFieldsCheck(parentVM, item, _self, lt(item.fld)) ]" auto-grow clearable