From 2b4aefff686ad78491f56fe2a09d73bc80de2e28 Mon Sep 17 00:00:00 2001 From: Fatimah Date: Thu, 1 Feb 2024 10:55:35 +0100 Subject: [PATCH] custom fields: added check for unfilled fields --- src/lib/forms/widgets/custom_fields/ComposeFields.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/forms/widgets/custom_fields/ComposeFields.js b/src/lib/forms/widgets/custom_fields/ComposeFields.js index b789969d..c20f7344 100644 --- a/src/lib/forms/widgets/custom_fields/ComposeFields.js +++ b/src/lib/forms/widgets/custom_fields/ComposeFields.js @@ -10,9 +10,10 @@ export class ComposeFields extends Component { constructor(props) { super(props); const { composeSections, record } = props; - const filled = Object.keys(record.custom_fields).map( - (key) => `custom_fields.${key}` - ); + const filled = + record.custom_fields && typeof record.custom_fields === "object" + ? Object.keys(record.custom_fields).map((key) => `custom_fields.${key}`) + : []; this.state = { sections: composeSections, tempFields: [], recordFields: filled }; this.fieldsCfg = this.getFieldsConfig(composeSections); this.sectionsList = composeSections.map((section) => section.section);