mirror of
https://github.com/directus/directus.git
synced 2026-01-23 02:18:00 -05:00
App: Fix saving required relational fields (#17842)
* Fix saving relational fields * Be more specific on variable name * Fix missing quotes
This commit is contained in:
@@ -11,7 +11,7 @@ import { validateItem } from '@/utils/validate-item';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { getEndpoint } from '@directus/shared/utils';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { merge } from 'lodash';
|
||||
import { mergeWith } from 'lodash';
|
||||
import { computed, ComputedRef, Ref, ref, watch } from 'vue';
|
||||
import { usePermissions } from './use-permissions';
|
||||
import { Field, Query, Relation } from '@directus/shared/types';
|
||||
@@ -120,12 +120,20 @@ export function useItem(
|
||||
saving.value = true;
|
||||
validationErrors.value = [];
|
||||
|
||||
const errors = validateItem(
|
||||
merge({}, defaultValues.value, item.value, edits.value),
|
||||
fieldsWithPermissions.value,
|
||||
isNew.value
|
||||
const payloadToValidate = mergeWith(
|
||||
{},
|
||||
defaultValues.value,
|
||||
item.value,
|
||||
edits.value,
|
||||
function (from: any, to: any) {
|
||||
if (typeof to !== 'undefined') {
|
||||
return to;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const errors = validateItem(payloadToValidate, fieldsWithPermissions.value, isNew.value);
|
||||
|
||||
if (errors.length > 0) {
|
||||
validationErrors.value = errors;
|
||||
saving.value = false;
|
||||
|
||||
Reference in New Issue
Block a user