From 67ca1c266fa7c03fd379bd397e215357c77189db Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 7 Sep 2022 02:14:50 +0800 Subject: [PATCH] Merge with M2M junction value when validating in drawer-item (#15433) * Merge with M2M junction value when validating in drawer-item * Simplify for null values * Clear validation error messages on save --- app/src/views/private/components/drawer-item.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/views/private/components/drawer-item.vue b/app/src/views/private/components/drawer-item.vue index 21a0073f4b..88227656c2 100644 --- a/app/src/views/private/components/drawer-item.vue +++ b/app/src/views/private/components/drawer-item.vue @@ -348,8 +348,9 @@ function useActions() { const editsToValidate = props.junctionField ? internalEdits.value[props.junctionField] : internalEdits.value; const fieldsToValidate = props.junctionField ? relatedCollectionFields.value : fieldsWithoutCircular.value; const defaultValues = getDefaultValuesFromFields(fieldsToValidate); + const existingValues = props.junctionField ? initialValues?.value?.[props.junctionField] : initialValues?.value; let errors = validateItem( - merge({}, defaultValues.value, initialValues.value, editsToValidate), + merge({}, defaultValues.value, existingValues, editsToValidate), fieldsToValidate, isNew.value ); @@ -357,6 +358,8 @@ function useActions() { if (errors.length > 0) { validationErrors.value = errors; return; + } else { + validationErrors.value = []; } if (props.junctionField && props.relatedPrimaryKey !== '+' && relatedPrimaryKeyField.value) {