This commit is contained in:
@@ -151,20 +151,15 @@ function getErrorBoxErrors(vm, errs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
todo: make a customFieldsCheck() rule, see todo.txt top item under "now"
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// REQUIRED
|
// REQUIRED
|
||||||
//
|
//
|
||||||
required(vm, ref, subvm) {
|
required(vm, ref) {
|
||||||
if (vm.formState.loading) {
|
if (vm.formState.loading) {
|
||||||
return false;
|
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);
|
var ctrl = getControl(vm, ref);
|
||||||
if (typeof ctrl == "undefined") {
|
if (typeof ctrl == "undefined") {
|
||||||
return false;
|
return false;
|
||||||
@@ -352,6 +347,41 @@ export default {
|
|||||||
return err;
|
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
|
// SERVER ERRORS
|
||||||
// Process and return server errors if any for form and field specified
|
// Process and return server errors if any for form and field specified
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -53,7 +53,14 @@
|
|||||||
:label="lt(item.fld)"
|
:label="lt(item.fld)"
|
||||||
:ref="item.fld"
|
:ref="item.fld"
|
||||||
:error-messages="form().serverErrors(parentVM, 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
|
auto-grow
|
||||||
clearable
|
clearable
|
||||||
></v-textarea>
|
></v-textarea>
|
||||||
|
|||||||
Reference in New Issue
Block a user