From 819f1a3472a86a111e14cf7175ac9d5e377687f2 Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 14 Sep 2021 16:44:11 +0800 Subject: [PATCH] fix: Field form values is not displayed --- .../src/components/admin-layout/Collections/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/client/src/components/admin-layout/Collections/index.tsx b/packages/client/src/components/admin-layout/Collections/index.tsx index ff8c884b7..cd9549a18 100644 --- a/packages/client/src/components/admin-layout/Collections/index.tsx +++ b/packages/client/src/components/admin-layout/Collections/index.tsx @@ -652,7 +652,7 @@ function CreateFieldButton() { } function EditFieldButton() { - const { refresh } = useCollectionsContext(); + const { refresh, findCollection } = useCollectionsContext(); const { service } = useTable(); const ctx = useContext(TableRowContext); const [visible, setVisible] = useState(false); @@ -688,7 +688,11 @@ function EditFieldButton() { type={'link'} onClick={() => { setVisible(true); - form.setValues(clone(ctx.record)); + const collection = findCollection(ctx.record.collection_name); + const values = collection?.generalFields?.find( + (field) => field.key === ctx.record.key, + ); + form.setValues(clone(values || {})); }} > 编辑