This commit is contained in:
2019-11-26 19:32:24 +00:00
parent 4571c24586
commit 1ebbd6e683
2 changed files with 19 additions and 19 deletions

View File

@@ -348,27 +348,32 @@ export default {
}, },
/////////////////////////////// ///////////////////////////////
// CUSTOMFIELDS // 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) { if (vm.formState.loading) {
return false; return false;
} }
if (window.$gz.errorHandler.devMode()) {
//make sure there is a customFields control in the refs to work with if(!templateItem.required){
//this is to ensure naming is correct mostly return false;
if (!window.$gz._.has(vm.$refs, "customFields")) {
throw "DEV ERROR gzform::customFieldsCheck() -> vm.$refs.customFields is missing. Is it named correctly?";
}
} }
debugger; var value=subvm.GetValueForField(templateItem.dataKey);
var value=subvm.GetValueForField(ref); if(!isEmpty(value)){
var ctrl= getControl(vm,"customFields"); return false;
var cdata = getControlValue(ctrl); }
//It's empty and it's required so return error
//TESTING: assume it's always a broken rule just to test if the rules will display properly
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}", // "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
var err = window.$gz.locale.get("ErrorRequiredFieldEmpty"); var err = window.$gz.locale.get("ErrorRequiredFieldEmpty");

View File

@@ -54,12 +54,7 @@
:ref="item.fld" :ref="item.fld"
:error-messages="form().serverErrors(parentVM, item.fld)" :error-messages="form().serverErrors(parentVM, item.fld)"
:rules="[ :rules="[
form().customFieldsCheck( form().customFieldsCheck(parentVM, item, _self, lt(item.fld))
parentVM,
item.dataKey,
_self,
lt(item.fld)
)
]" ]"
auto-grow auto-grow
clearable clearable