This commit is contained in:
@@ -151,20 +151,15 @@ function getErrorBoxErrors(vm, errs) {
|
||||
}
|
||||
|
||||
export default {
|
||||
todo: make a customFieldsCheck() rule, see todo.txt top item under "now"
|
||||
|
||||
///////////////////////////////
|
||||
// REQUIRED
|
||||
//
|
||||
required(vm, ref, subvm) {
|
||||
required(vm, ref) {
|
||||
if (vm.formState.loading) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(subvm){
|
||||
debugger;
|
||||
console.log("gzform:required() being called from custom fields control: ref=" + ref + " customFields value = " + vm.$refs.customFields.value);
|
||||
|
||||
}
|
||||
|
||||
var ctrl = getControl(vm, ref);
|
||||
if (typeof ctrl == "undefined") {
|
||||
return false;
|
||||
@@ -350,6 +345,41 @@ export default {
|
||||
valid: false
|
||||
});
|
||||
return err;
|
||||
},
|
||||
///////////////////////////////
|
||||
// CUSTOMFIELDS
|
||||
//
|
||||
customFieldsCheck(vm, ref, subvm, fieldName) {
|
||||
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?";
|
||||
}
|
||||
}
|
||||
|
||||
var ctrl= getControl(vm,"customFields");
|
||||
var cdata = getControlValue(ctrl);
|
||||
|
||||
return false;
|
||||
//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}",
|
||||
var err = window.$gz.locale.get("ErrorRequiredFieldEmpty");
|
||||
//var fieldName = getControlLabel(ctrl);
|
||||
err = window.$gz._.replace(err, "{0}", fieldName);
|
||||
//lodash replace only replaces first instance so need to do it twice
|
||||
err = window.$gz._.replace(err, "{0}", fieldName);
|
||||
//Update the form status
|
||||
this.setFormState({
|
||||
vm: vm,
|
||||
valid: false
|
||||
});
|
||||
return err;
|
||||
},
|
||||
///////////////////////////////
|
||||
// SERVER ERRORS
|
||||
|
||||
@@ -53,7 +53,14 @@
|
||||
:label="lt(item.fld)"
|
||||
:ref="item.fld"
|
||||
:error-messages="form().serverErrors(parentVM, item.fld)"
|
||||
:rules="[form().required(parentVM, item.fld, _self)]"
|
||||
:rules="[
|
||||
form().customFieldsCheck(
|
||||
parentVM,
|
||||
item.dataKey,
|
||||
_self,
|
||||
lt(item.fld)
|
||||
)
|
||||
]"
|
||||
auto-grow
|
||||
clearable
|
||||
></v-textarea>
|
||||
|
||||
Reference in New Issue
Block a user