From b1afaed0063934fcdcdf4c88b4877ecfa54858ed Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 17 Jun 2022 18:55:02 +0800 Subject: [PATCH] fix: revise form validations --- .../project/spreadsheet/views/FormView.vue | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/views/FormView.vue b/packages/nc-gui/components/project/spreadsheet/views/FormView.vue index e3c8639b56..fe0beb255a 100644 --- a/packages/nc-gui/components/project/spreadsheet/views/FormView.vue +++ b/packages/nc-gui/components/project/spreadsheet/views/FormView.vue @@ -617,35 +617,21 @@ export default { ) { continue } - if ( - !column.virtual && - (((column.rqd || column.notnull) && !column.cdf) || - (column.pk && !(column.ai || column.default)) || - this.localParams.fields[column.title].required) - ) { + if (!isVirtualCol(column) && (((column.rqd || column.notnull) && !column.cdf) || (column.pk && !(column.ai || column.cdf)) || column.required)) { obj.localState[column.title] = { required } - } else if (column.bt) { - const col = this.meta.columns.find( - c => c.column_name === column.bt.column_name - ) - if ( - (col.rqd && !col.default) || - this.localParams.fields[column.title].required - ) { - obj.localState[col.title] = { required } + } else if (column.uidt === UITypes.LinkToAnotherRecord && column.colOptions && column.colOptions.type === RelationTypes.BELONGS_TO) { + const col = this.meta.columns.find(c => c.id === column.colOptions.fk_child_column_id) + + if ((col && col.rqd && !col.cdf) || column.required) { + if (col) { obj.virtual[column.title] = { required } } } - } else if ( - column.virtual && - this.localParams.fields[column.title].required && - (column.mm || column.hm) - ) { + } else if (isVirtualCol(column) && column.required) { obj.virtual[column.title] = { minLength: minLength(1), required } } } - return obj }, computed: {