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
// 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");

View File

@@ -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