@@ -196,24 +196,11 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
196196 } ;
197197
198198 // ================================== Utils ==================================
199- public getNamePath = ( name ?: InternalNamePath ) : InternalNamePath => {
200- const { name : propsName , fieldContext } = this . props ;
201- const _name = name ?? propsName ;
202-
203- const { prefixName = [ ] } : InternalFormInstance = fieldContext ;
204-
205- return _name !== undefined ? [ ...prefixName , ..._name ] : [ ] ;
206- } ;
207-
208- public getNamesPath = ( ) : InternalNamePath | InternalNamePath [ ] => {
209- const { name, names, fieldContext } = this . props ;
210-
199+ public getNamePath = ( ) : InternalNamePath => {
200+ const { name, fieldContext } = this . props ;
211201 const { prefixName = [ ] } : InternalFormInstance = fieldContext ;
212- if ( name ) {
213- return name !== undefined ? [ ...prefixName , ...name ] : [ ] ;
214- }
215202
216- return names !== undefined ? names . map ( name => [ ...prefixName , ...name ] ) : [ ] ;
203+ return name !== undefined ? [ ...prefixName , ...name ] : [ ] ;
217204 } ;
218205
219206 public getRules = ( ) : RuleObject [ ] => {
@@ -569,15 +556,9 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
569556
570557 // ============================== Field Control ==============================
571558 public getValue = ( store ?: Store ) => {
572- const { names } = this . props ;
573559 const { getFieldsValue } : FormInstance = this . props . fieldContext ;
574- if ( names ) {
575- const namesValue = names . map ( name => {
576- return getValue ( store || getFieldsValue ( true ) , this . getNamePath ( name ) ) ;
577- } ) ;
578- return namesValue ;
579- }
580- return getValue ( store || getFieldsValue ( true ) , this . getNamePath ( ) ) ;
560+ const namePath = this . getNamePath ( ) ;
561+ return getValue ( store || getFieldsValue ( true ) , namePath ) ;
581562 } ;
582563
583564 public getControlled = ( childProps : ChildProps = { } ) => {
@@ -594,7 +575,7 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
594575 const mergedValidateTrigger =
595576 validateTrigger !== undefined ? validateTrigger : fieldContext . validateTrigger ;
596577
597- const namesPath = this . getNamesPath ( ) ;
578+ const namePath = this . getNamePath ( ) ;
598579 const { getInternalHooks, getFieldsValue } : InternalFormInstance = fieldContext ;
599580 const { dispatch } = getInternalHooks ( HOOK_MARK ) ;
600581 const value = this . getValue ( ) ;
@@ -614,6 +595,7 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
614595 ) ;
615596 } ) ;
616597 }
598+
617599 const control = {
618600 ...childProps ,
619601 ...valueProps ,
@@ -637,12 +619,11 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
637619 if ( normalize ) {
638620 newValue = normalize ( newValue , value , getFieldsValue ( true ) ) ;
639621 }
640- namesPath . forEach ( ( name , index ) => {
641- dispatch ( {
642- type : 'updateValue' ,
643- namePath : this . getNamePath ( name ) ,
644- value : newValue [ index ] ,
645- } ) ;
622+
623+ dispatch ( {
624+ type : 'updateValue' ,
625+ namePath,
626+ value : newValue ,
646627 } ) ;
647628
648629 if ( originTriggerFunc ) {
@@ -666,12 +647,10 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
666647 if ( rules && rules . length ) {
667648 // We dispatch validate to root,
668649 // since it will update related data with other field with same name
669- namesPath . forEach ( name => {
670- dispatch ( {
671- type : 'validateField' ,
672- namePath : this . getNamePath ( name ) ,
673- triggerName,
674- } ) ;
650+ dispatch ( {
651+ type : 'validateField' ,
652+ namePath,
653+ triggerName,
675654 } ) ;
676655 }
677656 } ;
0 commit comments