Skip to content

Commit a279a38

Browse files
Merge branch 'dev' into feature/Fix-Issue1953
2 parents 0e1df59 + 8f2114d commit a279a38

4 files changed

Lines changed: 25 additions & 13 deletions

File tree

CHANGELOG.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"`ModernTaxonomyPicker` allowMultipleSelections = false, but panel allows multiple items to be selected [#1847](https://github.com/pnp/sp-dev-fx-controls-react/issues/1847)",
2424
"`UserPicker` fix exports and add missing link to documentation [#1925](https://github.com/pnp/sp-dev-fx-controls-react/issues/1925)",
2525
"Optimizing ControlsTest webpart in the SPFx source project [#1951](https://github.com/pnp/sp-dev-fx-controls-react/pull/1951)",
26-
"[Dynamic Form] Not handling mandatory Lookup fields well [#1914](https://github.com/pnp/sp-dev-fx-controls-react/issues/1914)"
26+
"[DynamicForm] Not handling mandatory Lookup fields well [#1914](https://github.com/pnp/sp-dev-fx-controls-react/issues/1914)",
27+
"[DynamicForm] Loads with Validation Errors if no List Item Id is set [#1655](https://github.com/pnp/sp-dev-fx-controls-react/issues/1655)"
2728
]
2829
},
2930
"contributions": [

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
- `ModernTaxonomyPicker` allowMultipleSelections = false, but panel allows multiple items to be selected [#1847](https://github.com/pnp/sp-dev-fx-controls-react/issues/1847)
2525
- `UserPicker` fix exports and add missing link to documentation [#1925](https://github.com/pnp/sp-dev-fx-controls-react/issues/1925)
2626
- Optimizing ControlsTest webpart in the SPFx source project [#1951](https://github.com/pnp/sp-dev-fx-controls-react/pull/1951)
27-
- [Dynamic Form] Not handling mandatory Lookup fields well [#1914](https://github.com/pnp/sp-dev-fx-controls-react/issues/1914)
27+
- [DynamicForm] Not handling mandatory Lookup fields well [#1914](https://github.com/pnp/sp-dev-fx-controls-react/issues/1914)
28+
- [DynamicForm] Loads with Validation Errors if no List Item Id is set [#1655](https://github.com/pnp/sp-dev-fx-controls-react/issues/1655)
2829

2930
### Contributors
3031

docs/documentation/docs/about/release-notes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
- `ModernTaxonomyPicker` allowMultipleSelections = false, but panel allows multiple items to be selected [#1847](https://github.com/pnp/sp-dev-fx-controls-react/issues/1847)
2525
- `UserPicker` fix exports and add missing link to documentation [#1925](https://github.com/pnp/sp-dev-fx-controls-react/issues/1925)
2626
- Optimizing ControlsTest webpart in the SPFx source project [#1951](https://github.com/pnp/sp-dev-fx-controls-react/pull/1951)
27-
- [Dynamic Form] Not handling mandatory Lookup fields well [#1914](https://github.com/pnp/sp-dev-fx-controls-react/issues/1914)
27+
- [DynamicForm] Not handling mandatory Lookup fields well [#1914](https://github.com/pnp/sp-dev-fx-controls-react/issues/1914)
28+
- [DynamicForm] Loads with Validation Errors if no List Item Id is set [#1655](https://github.com/pnp/sp-dev-fx-controls-react/issues/1655)
2829

2930
### Contributors
3031

src/controls/dynamicForm/dynamicField/DynamicField.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -644,15 +644,20 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
644644
const {
645645
changedValue
646646
} = this.state;
647-
const {value,newValue,required}=this.props;
648-
if(newValue===undefined){
649-
return required && (changedValue === undefined || changedValue === '' || changedValue === null || this.isEmptyArray(changedValue))
650-
&& (value === undefined || value === '' || value === null || this.isEmptyArray(value) || this.checkUserArrayIsEmpty(value))? strings.DynamicFormRequiredErrorMessage : null;
651-
}
652-
else{
653-
return required && (changedValue === undefined || changedValue === '' || changedValue === null || this.isEmptyArray(changedValue) || this.checkUserArrayIsEmpty(changedValue)) ? strings.DynamicFormRequiredErrorMessage : null;
647+
648+
const { value, newValue, required,listItemId } = this.props;
649+
650+
if (listItemId !== undefined && listItemId !== null) {
651+
if (newValue === undefined) {
652+
return required && (changedValue === undefined || changedValue === '' || changedValue === null || this.isEmptyArray(changedValue))
653+
&& (value === undefined || value === '' || value === null || this.isEmptyArray(value)) || this.checkUserArrayIsEmpty(value)) ? strings.DynamicFormRequiredErrorMessage : null;
654+
} else {
655+
return required && (changedValue === undefined || changedValue === '' || changedValue === null || this.isEmptyArray(changedValue)) || this.checkUserArrayIsEmpty(value)) ? strings.DynamicFormRequiredErrorMessage : null;
656+
}
654657
}
655658

659+
return null;
660+
656661
}
657662

658663
private getNumberErrorText = (): string => {
@@ -667,17 +672,21 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
667672
showAsPercentage,
668673
value,
669674
newValue,
670-
required
675+
required,
676+
listItemId
671677
} = this.props;
672678

673679
if (required && newValue!==undefined && (changedValue === undefined || changedValue === '' || changedValue === null || this.isEmptyArray(changedValue)) ) {
674680
return strings.DynamicFormRequiredErrorMessage;
675681
}
676682

677-
if (required && newValue===undefined && (value === undefined || value === '' || value === null || this.isEmptyArray(value)) && (changedValue === undefined || changedValue === '' || changedValue === null || this.isEmptyArray(changedValue)) ) {
678-
return strings.DynamicFormRequiredErrorMessage;
683+
if(listItemId !== undefined && listItemId !== null){
684+
if (required && newValue===undefined && (value === undefined || value === '' || value === null || this.isEmptyArray(value)) && (changedValue === undefined || changedValue === '' || changedValue === null || this.isEmptyArray(changedValue)) ) {
685+
return strings.DynamicFormRequiredErrorMessage;
686+
}
679687
}
680688

689+
681690
let minValue = minimumValue !== undefined && minimumValue !== -(Number.MAX_VALUE) ? minimumValue : undefined;
682691
let maxValue = maximumValue !== undefined && maximumValue !== Number.MAX_VALUE ? maximumValue : undefined;
683692

0 commit comments

Comments
 (0)