Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamicForm - Check if hiddenfields property is undefined #1314

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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