Skip to content

add optional labelFn prop to SimpleFormIterator #6292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/ra-ui-materialui/src/form/SimpleFormIterator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const SimpleFormIterator: FC<SimpleFormIteratorProps> = props => {
margin,
TransitionProps,
defaultValue,
labelFn = (index) => (index + 1),
} = props;
const classes = useStyles(props);
const nodeRef = useRef(null);
Expand Down Expand Up @@ -197,7 +198,7 @@ const SimpleFormIterator: FC<SimpleFormIteratorProps> = props => {
variant="body1"
className={classes.index}
>
{index + 1}
{labelFn(index)}
</Typography>
<section className={classes.form}>
{Children.map(
Expand Down Expand Up @@ -326,6 +327,7 @@ export interface SimpleFormIteratorProps
disabled?: boolean;
disableAdd?: boolean;
disableRemove?: boolean | DisableRemoveFunction;
labelFn?: (index: number) => string;
margin?: 'none' | 'normal' | 'dense';
meta?: {
// the type defined in FieldArrayRenderProps says error is boolean, which is wrong.
Expand Down