This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user