From 810bd66288c97c021c80b6d0bc6db4a92fe162cf Mon Sep 17 00:00:00 2001 From: Alan Poulain Date: Sat, 16 May 2020 18:42:25 +0200 Subject: [PATCH] Fix useInitializeFormWithRecord with an array of objects --- packages/ra-core/src/form/useInitializeFormWithRecord.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/ra-core/src/form/useInitializeFormWithRecord.ts b/packages/ra-core/src/form/useInitializeFormWithRecord.ts index 1626296b7be..455c071b296 100644 --- a/packages/ra-core/src/form/useInitializeFormWithRecord.ts +++ b/packages/ra-core/src/form/useInitializeFormWithRecord.ts @@ -1,5 +1,6 @@ import { useEffect } from 'react'; import { useForm } from 'react-final-form'; +import { isObject } from '../inference/assertions'; /** * Restore the record values which should override any default values specified on the form. @@ -24,7 +25,10 @@ const useInitializeFormWithRecord = record => { if (Array.isArray(record[key])) { // array of values record[key].forEach((value, index) => { - if (value && Object.keys(value).length > 0) { + if ( + isObject(value) && + Object.keys(value).length > 0 + ) { // array of objects Object.keys(value).forEach(key2 => { form.change(