Skip to content

Commit

Permalink
feat: Support labelFor props in <FormItem/> (#3974)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan0314 authored Oct 6, 2023
1 parent d51b4f2 commit eeac65c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/antd/src/form-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface IFormItemProps {
tooltipLayout?: 'icon' | 'text'
labelStyle?: React.CSSProperties
labelAlign?: 'left' | 'right'
labelFor?: string
labelWrap?: boolean
labelWidth?: number | string
wrapperWidth?: number | string
Expand Down Expand Up @@ -238,6 +239,7 @@ export const BaseItem: React.FC<React.PropsWithChildren<IFormItemProps>> = ({
<span className={`${prefixCls}-asterisk`}>{'*'}</span>
)}
<label>{label}</label>
<label htmlFor={props.labelFor}>{label}</label>
{!asterisk && requiredMark === 'optional' && !optionalMarkHidden && (
<span className={`${prefixCls}-optional`}>
{locale?.Form?.optional}
Expand Down
2 changes: 2 additions & 0 deletions packages/next/src/form-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface IFormItemProps {
tooltip?: React.ReactNode
tooltipLayout?: 'icon' | 'text'
tooltipIcon?: React.ReactNode
labelFor?: string
labelStyle?: React.CSSProperties
labelAlign?: 'left' | 'right'
labelWrap?: boolean
Expand Down Expand Up @@ -227,6 +228,7 @@ export const BaseItem: React.FC<React.PropsWithChildren<IFormItemProps>> = (
<span className={cls(`${prefixCls}-asterisk`)}>{'*'}</span>
)}
<label>{label}</label>
<label htmlFor={props.labelFor}>{label}</label>
</span>
</div>
)
Expand Down

0 comments on commit eeac65c

Please sign in to comment.