Fixing 1711 - Bug with default taxonomy value

Added regex clean-up of the taxonomy strings in readData()
This commit is contained in:
Fredrik Thorild 2021-02-21 07:59:15 +01:00
parent 181f815aa7
commit c0adbde8a9
1 changed files with 9 additions and 1 deletions

View File

@ -298,7 +298,15 @@ class ListForm extends React.Component<IListFormProps, IListFormState> {
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;
}