Skip to content

Commit c104482

Browse files
authored
Merge pull request #474 from devforth/feature/AdminForth/1227/for-best-ux-value-edit-rendere
fix: added the ability to accept an object if the json type is specified
2 parents 334bd02 + 17718ae commit c104482

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

adminforth/spa/src/components/ResourceForm.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,11 @@ const columnError = (column: AdminForthResourceColumnCommon) => {
129129
}
130130
}
131131
if (column.type === 'json' && !column.isArray?.enabled && currentValues.value[column.name]) {
132+
const value = currentValues.value[column.name];
132133
try {
133-
JSON.parse(currentValues.value[column.name]);
134+
if (typeof value === 'object') {
135+
JSON.parse(JSON.stringify(value));
136+
}
134137
} catch (e) {
135138
return t('Invalid JSON');
136139
}
@@ -286,10 +289,11 @@ onMounted(() => {
286289
}
287290
}
288291
} else if (currentValues.value[column.name]) {
289-
currentValues.value[column.name] = JSON.stringify(currentValues.value[column.name], null, 2);
292+
if (typeof currentValues.value[column.name] !== 'string') {
293+
currentValues.value[column.name] = JSON.stringify(currentValues.value[column.name], null, 2)
294+
}
295+
}
290296
}
291-
292-
}
293297
});
294298
emit('update:isValid', isValid.value);
295299
});

0 commit comments

Comments
 (0)