From 1482d7f4d253dcb85cc1d0d51a5d1b3c58190e3b Mon Sep 17 00:00:00 2001 From: Pavlo Kulyk Date: Thu, 19 Feb 2026 16:25:19 +0200 Subject: [PATCH] add comment to fix: allow json fields to accept objects in edit mode without validation errors --- adminforth/spa/src/components/ResourceForm.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/adminforth/spa/src/components/ResourceForm.vue b/adminforth/spa/src/components/ResourceForm.vue index 0185765e..30d31b64 100644 --- a/adminforth/spa/src/components/ResourceForm.vue +++ b/adminforth/spa/src/components/ResourceForm.vue @@ -131,6 +131,7 @@ const columnError = (column: AdminForthResourceColumnCommon) => { if (column.type === 'json' && !column.isArray?.enabled && currentValues.value[column.name]) { const value = currentValues.value[column.name]; try { + // add object check to allow json fields to be objects in edit mode without throwing validation error, but still validate if the string is a valid json or not if (typeof value === 'object') { JSON.parse(JSON.stringify(value)); } @@ -289,6 +290,8 @@ onMounted(() => { } } } else if (currentValues.value[column.name]) { + // Todo: reconsider basic issue + // if value is not string, we should stringify it, but object we already stringify in setCurrentValue, so we should not stringify it again to prevent double stringification if (typeof currentValues.value[column.name] !== 'string') { currentValues.value[column.name] = JSON.stringify(currentValues.value[column.name], null, 2) }