{"record":{"id":"36f7ee3af1da1a8b","repo":"marmelab/react-admin","slug":"simpleformiterator-can-only-be-called-within-an-it-36f7ee","errorCode":null,"errorMessage":"SimpleFormIterator can only be called within an iterator input like ArrayInput","messagePattern":"SimpleFormIterator can only be called within an iterator input like ArrayInput","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-ui-materialui/src/input/ArrayInput/SimpleFormIterator.tsx","lineNumber":60,"sourceCode":"        addButton = <DefaultAddItemButton />,\n        removeButton,\n        reOrderButtons,\n        children,\n        className,\n        disabled,\n        disableAdd = false,\n        disableClear,\n        disableRemove = false,\n        disableReordering,\n        inline,\n        getItemLabel = false,\n        fullWidth,\n        sx,\n    } = props;\n\n    const finalSource = useWrappedSource('');\n    if (!finalSource) {\n        throw new Error(\n            'SimpleFormIterator can only be called within an iterator input like ArrayInput'\n        );\n    }\n    const { fields } = useArrayInput(props);\n    const record = useRecordContext(props);\n    const records = get(record, finalSource);\n    const getArrayInputNewItemDefaults =\n        useGetArrayInputNewItemDefaults(fields);\n\n    const getItemDefaults = useEvent((item: any = undefined) => {\n        if (item != null) return item;\n        return getArrayInputNewItemDefaults(children);\n    });\n\n    return (\n        <SimpleFormIteratorBase getItemDefaults={getItemDefaults} {...props}>\n            <Root\n                className={clsx(","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-ui-materialui/src/input/ArrayInput/SimpleFormIterator.tsx#L42-L78","documentation":"<SimpleFormIterator> renders the rows of an <ArrayInput>; it relies on the iterator context that ArrayInput provides (via useWrappedSource/useArrayInput) to know which array field it manages. Used outside such an input, the wrapped source is empty and it throws.","triggerScenarios":"Placing <SimpleFormIterator> directly inside a form (not inside <ArrayInput>); using it inside <ReferenceManyField> or other non-iterator inputs; nesting it outside any input that supplies iterator context.","commonSituations":"Copy-pasting SimpleFormIterator into a plain SimpleForm; trying to reuse it for ReferenceManyField lists; refactoring forms and accidentally un-nesting it from ArrayInput.","solutions":["Always nest it inside <ArrayInput>: `<ArrayInput source=\"tags\"><SimpleFormIterator><TextField source=\"name\" /></SimpleFormIterator></ArrayInput>`.","For related-record lists use <ReferenceManyField> with its own iterator (e.g. <Datagrid> or <SimpleList>), not SimpleFormIterator.","If you need a custom iterator, build it on the iterator context that ArrayInput provides."],"exampleFix":"// before\n<SimpleForm>\n  <SimpleFormIterator>\n    <TextField source=\"name\" />\n  </SimpleFormIterator>\n</SimpleForm>\n\n// after\n<SimpleForm>\n  <ArrayInput source=\"tags\">\n    <SimpleFormIterator>\n      <TextField source=\"name\" />\n    </SimpleFormIterator>\n  </ArrayInput>\n</SimpleForm>","handlingStrategy":"validation","validationCode":"// Ensure SimpleFormIterator is a direct child of ArrayInput\n<CheckIteratorParent>{children}</CheckIteratorParent> // or assert useWrappedSource('') returns non-empty in dev","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always nest SimpleFormIterator inside <ArrayInput>.","Use ReferenceManyField + Datagrid for related lists, not SimpleFormIterator.","Code-review form JSX nesting when refactoring."],"tags":["react-admin","arrayinput","simpleformiterator","invalid-usage"],"backgroundTag":"component-used-outside-provider","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}