File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
packages/ra-core/src/form Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -72,11 +72,11 @@ export const FormDataConsumerView = <
7272 const finalSource = useWrappedSource ( source || '' ) ;
7373
7474 // Passes an empty string here as we don't have the children sources and we just want to know if we are in an iterator
75- const matches = ArraySourceRegex . exec ( finalSource ) ;
75+ const arraySource = getArraySource ( finalSource ) ;
7676
7777 // If we have an index, we are in an iterator like component (such as the SimpleFormIterator)
78- if ( matches ) {
79- const scopedFormData = get ( formData , matches [ 0 ] ) ;
78+ if ( arraySource ) {
79+ const scopedFormData = get ( formData , arraySource ) ;
8080 result = children ( { formData, scopedFormData } ) ;
8181 } else {
8282 result = children ( { formData } ) ;
@@ -85,7 +85,12 @@ export const FormDataConsumerView = <
8585 return result === undefined ? null : result ;
8686} ;
8787
88- const ArraySourceRegex = new RegExp ( / .+ \. \d + $ / ) ;
88+ const getArraySource = ( source : string ) =>
89+ source . lastIndexOf ( '.' ) > 0 && ArraySourceRegex . test ( source )
90+ ? source
91+ : undefined ;
92+
93+ const ArraySourceRegex = / \. \d + $ / ;
8994
9095export interface FormDataConsumerRenderParams <
9196 TFieldValues extends FieldValues = FieldValues ,
You can’t perform that action at this time.
0 commit comments