@@ -360,6 +360,7 @@ const ZenstackBaseForm = (props: ZenstackBaseFormProps) => {
360
360
key = { fieldName }
361
361
field = { field }
362
362
index = { - 1 }
363
+ className = { element . props . className }
363
364
{ ...props }
364
365
/>
365
366
) ;
@@ -451,6 +452,7 @@ interface ZenstackFormInputProps extends ZenstackBaseFormProps {
451
452
field : Field
452
453
index : number
453
454
customElement ?: React . ReactElement
455
+ className ?: string
454
456
}
455
457
const ZenstackFormInputInternal = ( props : ZenstackFormInputProps ) => {
456
458
const { metadata : originalMetadata , elementMap, hooks, enumLabelTransformer } = useZenstackUIProvider ( ) ;
@@ -588,12 +590,16 @@ const ZenstackFormInputInternal = (props: ZenstackFormInputProps) => {
588
590
589
591
// If we have a custom element, use it instead of the element mapping
590
592
if ( props . customElement ) {
593
+ const originalClassName = props . customElement . props . className || '' ;
594
+ const dirtyClassName = isDirty ? 'dirty' : '' ;
595
+ const combinedClassName = `${ originalClassName } ${ dirtyClassName } ` . trim ( ) ;
596
+
591
597
return React . cloneElement ( props . customElement , {
592
598
...props . form . getInputProps ( fieldName ) ,
593
599
onChange : handleChange ,
594
600
required,
595
601
key : props . form . key ( fieldName ) ,
596
- className : isDirty ? 'dirty' : '' ,
602
+ className : combinedClassName ,
597
603
disabled : isDisabled ,
598
604
placeholder : placeholder ,
599
605
} ) ;
@@ -608,7 +614,7 @@ const ZenstackFormInputInternal = (props: ZenstackFormInputProps) => {
608
614
onChange = { handleChange } // Override onChange with our wrapped version
609
615
label = { label }
610
616
data = { labelData }
611
- className = { isDirty ? 'dirty' : '' }
617
+ className = { ` ${ props . className || '' } ${ isDirty ? 'dirty' : '' } ` . trim ( ) }
612
618
disabled = { isDisabled }
613
619
data-autofocus = { props . index === 0 }
614
620
/>
0 commit comments