@@ -662,29 +662,38 @@ export class FormStore extends ActionEmitter {
662
662
protected BuildFormObject ( fieldsGroupId ?: string ) : Dictionary {
663
663
const result : Dictionary = { } ;
664
664
665
- const groupFields = this . State . Fields . filter ( x =>
666
- x != null &&
667
- ( x . FieldsGroup == null || x . FieldsGroup . Id === fieldsGroupId ) ) ;
665
+ const groupFields = this . State . Fields . filter ( x => {
666
+ // If the field is null (never)
667
+ if ( x == null ) {
668
+ return false ;
669
+ }
670
+
671
+ if ( x . FieldsGroup == null ) {
672
+ return fieldsGroupId == null ;
673
+ } else {
674
+ return x . FieldsGroup . Id === fieldsGroupId ;
675
+ }
676
+ } ) ;
668
677
669
678
groupFields . forEach ( ( field , fieldId ) => {
670
- if ( field == null || field == null ) {
679
+ if ( field == null || fieldId == null ) {
671
680
return ;
672
681
}
673
682
result [ field . Name ] = field . Value ;
674
683
} ) ;
675
684
676
685
const fieldsGroups = this . State . FieldsGroups . filter ( x => x != null && x . Parent === fieldsGroupId ) ;
677
- fieldsGroups . forEach ( ( fieldsGroup , index ) => {
678
- if ( fieldsGroup == null || index == null ) {
686
+ fieldsGroups . forEach ( ( fieldsGroup , fieldId ) => {
687
+ if ( fieldsGroup == null || fieldId == null ) {
679
688
return ;
680
689
}
681
690
if ( fieldsGroup . ArrayName != null ) {
682
691
if ( result [ fieldsGroup . ArrayName ] == null ) {
683
692
result [ fieldsGroup . ArrayName ] = [ ] ;
684
693
}
685
- result [ fieldsGroup . ArrayName ] . push ( this . BuildFormObject ( index ) ) ;
694
+ result [ fieldsGroup . ArrayName ] . push ( this . BuildFormObject ( fieldId ) ) ;
686
695
} else {
687
- result [ fieldsGroup . Name ] = this . BuildFormObject ( index ) ;
696
+ result [ fieldsGroup . Name ] = this . BuildFormObject ( fieldId ) ;
688
697
}
689
698
} ) ;
690
699
return result ;
0 commit comments