Skip to content

Commit 4721fca

Browse files
authored
Merge pull request #483 from devforth/feature/AdminForth/1227/for-best-ux-value-edit-rendere
add comment to fix: allow json fields to accept objects in edit mode …
2 parents d58b92d + 1482d7f commit 4721fca

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

adminforth/spa/src/components/ResourceForm.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ const columnError = (column: AdminForthResourceColumnCommon) => {
146146
if (column.type === 'json' && !column.isArray?.enabled && currentValues.value[column.name]) {
147147
const value = currentValues.value[column.name];
148148
try {
149+
// 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
149150
if (typeof value === 'object') {
150151
JSON.parse(JSON.stringify(value));
151152
}
@@ -304,6 +305,8 @@ onMounted(() => {
304305
}
305306
}
306307
} else if (currentValues.value[column.name]) {
308+
// Todo: reconsider basic issue
309+
// 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
307310
if (typeof currentValues.value[column.name] !== 'string') {
308311
currentValues.value[column.name] = JSON.stringify(currentValues.value[column.name], null, 2)
309312
}

0 commit comments

Comments
 (0)