From c0adbde8a93f3adab8fa64e55f151d455fc0dee4 Mon Sep 17 00:00:00 2001 From: Fredrik Thorild Date: Sun, 21 Feb 2021 07:59:15 +0100 Subject: [PATCH] Fixing 1711 - Bug with default taxonomy value Added regex clean-up of the taxonomy strings in readData() --- .../src/webparts/listForm/components/ListForm.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/samples/react-list-form/src/webparts/listForm/components/ListForm.tsx b/samples/react-list-form/src/webparts/listForm/components/ListForm.tsx index a8bc5b28c..569ab0b5a 100644 --- a/samples/react-list-form/src/webparts/listForm/components/ListForm.tsx +++ b/samples/react-list-form/src/webparts/listForm/components/ListForm.tsx @@ -298,7 +298,15 @@ class ListForm extends React.Component { try { if ((formType === ControlMode.New) || !id) { const data = this.state.fieldsSchema - .reduce((newData, fld) => { newData[fld.InternalName] = fld.DefaultValue; return newData; }, {}); + .reduce((newData, fld) => { + if (fld.DefaultValue && fld.FieldType.indexOf("TaxonomyField") > -1) { + newData[fld.InternalName] = fld.DefaultValue.replace(new RegExp("([#]?[0-9]+;#)", "g"), "") + } else { + newData[fld.InternalName] = fld.DefaultValue; + } + return newData; + }, + {}); this.setState({ ...this.state, data: data, originalData: { ...data }, fieldErrors: {}, isLoadingData: false }); return; }