@@ -356,9 +356,10 @@ function walkFormField(field: any, type: string, parentPath: string, out: Expect
356356 const name = typeof field . field === 'string' ? field . field : undefined ;
357357 const path = name ? ( parentPath ? `${ parentPath } .${ name } ` : name ) : parentPath ;
358358 if ( path ) {
359- if ( typeof field . label === 'string' && field . label . length > 0 ) {
360- pushEntry ( out , [ 'metadataForms' , type , 'fields' , path , 'label' ] , field . label , 'metadataFormField' , { metadataType : type } ) ;
361- }
359+ const label = typeof field . label === 'string' && field . label . length > 0
360+ ? field . label
361+ : humanizeFieldPath ( path ) ;
362+ pushEntry ( out , [ 'metadataForms' , type , 'fields' , path , 'label' ] , label , 'metadataFormField' , { metadataType : type } ) ;
362363 if ( typeof field . helpText === 'string' && field . helpText . length > 0 ) {
363364 pushEntry ( out , [ 'metadataForms' , type , 'fields' , path , 'helpText' ] , field . helpText , 'metadataFormField' , { metadataType : type } ) ;
364365 }
@@ -371,6 +372,15 @@ function walkFormField(field: any, type: string, parentPath: string, out: Expect
371372 }
372373}
373374
375+ /** Match the metadata form renderer's fallback label for fields without an explicit label. */
376+ function humanizeFieldPath ( path : string ) : string {
377+ const leaf = path . split ( '.' ) . pop ( ) ?? path ;
378+ return leaf
379+ . replace ( / ( [ a - z 0 - 9 ] ) ( [ A - Z ] ) / g, '$1 $2' )
380+ . replace ( / [ _ - ] + / g, ' ' )
381+ . replace ( / \b \w / g, ( c ) => c . toUpperCase ( ) ) ;
382+ }
383+
374384/**
375385 * Section-name derivation mirroring `resolveMetadataFormLabels` so the
376386 * extractor emits keys at the exact same paths the resolver looks them up.
0 commit comments