Skip to content

Commit

Permalink
Merge pull request #1314 from SmarterJB/bugfix/hiddenFieldsCheckForUn…
Browse files Browse the repository at this point in the history
…defined

DynamicForm - Check if hiddenfields property is undefined
  • Loading branch information
joelfmrodrigues authored Sep 19, 2022
2 parents d175f61 + bdcec90 commit 6025ab8
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/controls/dynamicForm/DynamicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,12 @@ export class DynamicForm extends React.Component<IDynamicFormProps, IDynamicForm
const tempFields: IDynamicFieldProps[] = [];
let order: number = 0;
const responseValue = listFeilds.value;
const hiddenFields = this.props.hiddenFields !== undefined ? this.props.hiddenFields : [];
for (let i = 0, len = responseValue.length; i < len; i++) {
const field = responseValue[i];

// Handle only fields that are not marked as hidden
if (this.props.hiddenFields.indexOf(field.EntityPropertyName) < 0) {
if (hiddenFields.indexOf(field.EntityPropertyName) < 0) {
order++;
const fieldType = field.TypeAsString;
field.order = order;
Expand Down Expand Up @@ -370,7 +371,7 @@ export class DynamicForm extends React.Component<IDynamicFormProps, IDynamicForm
else {
defaultValue = [];
}

}
else if (fieldType === "LookupMulti") {
lookupListId = field.LookupList;
Expand All @@ -390,7 +391,7 @@ export class DynamicForm extends React.Component<IDynamicFormProps, IDynamicForm
item[field.InternalName].forEach(element => {
selectedTags.push({ key: element.TermGuid, name: element.Label });
});

defaultValue = selectedTags;
}
else {
Expand All @@ -399,15 +400,15 @@ export class DynamicForm extends React.Component<IDynamicFormProps, IDynamicForm
if (element.indexOf('|') !== -1)
selectedTags.push({ key: element.split('|')[1], name: element.split('|')[0] });
});

defaultValue = selectedTags;
}
}
if (defaultValue === "")
defaultValue = null;
}
else if (fieldType === "TaxonomyFieldType") {

termSetId = field.TermSetId;
if (item !== null) {
const response = await this._spService.getSingleManagedMtadataLabel(listId, listItemId, field.InternalName);
Expand All @@ -431,11 +432,11 @@ export class DynamicForm extends React.Component<IDynamicFormProps, IDynamicForm
else if (defaultValue === '[today]') {
defaultValue = new Date();
}

const schemaXml = field.SchemaXml;
const dateFormatRegEx = /\s+Format="([^"]+)"/gmi.exec(schemaXml);
dateFormat = dateFormatRegEx && dateFormatRegEx.length ? dateFormatRegEx[1] as DateFormat : 'DateOnly';

}
else if (fieldType === "UserMulti") {
if (item !== null)
Expand Down Expand Up @@ -469,7 +470,7 @@ export class DynamicForm extends React.Component<IDynamicFormProps, IDynamicForm
else if (fieldType === "Boolean") {
defaultValue = Boolean(Number(defaultValue));
}

tempFields.push({
newValue: null,
fieldTermSetId: termSetId,
Expand Down

0 comments on commit 6025ab8

Please sign in to comment.