{"record":{"id":"8b50c0846a7baa27","repo":"marmelab/react-admin","slug":"simpleformiterator-can-only-be-called-within-an-it-8b50c0","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":null,"httpStatus":null,"severity":"error","filePath":"packages/ra-core/src/test-ui/SimpleFormIterator.tsx","lineNumber":196,"sourceCode":"        addButton = <DefaultAddItemButton />,\n        removeButton,\n        reOrderButtons,\n        children,\n        className,\n        resource,\n        disabled,\n        disableAdd = false,\n        disableClear,\n        disableRemove = false,\n        disableReordering,\n        inline,\n        getItemLabel = false,\n        fullWidth,\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\n    const [confirmIsOpen, setConfirmIsOpen] = useState<boolean>(false);\n    const { fields, remove } = useArrayInput(props);\n    const translate = useTranslate();\n\n    const handleArrayClear = useCallback(() => {\n        remove();\n        setConfirmIsOpen(false);\n    }, [remove]);\n\n    const records = useFieldValue({ source: finalSource });\n    const getArrayInputNewItemDefaults =\n        useGetArrayInputNewItemDefaults(fields);\n\n    const getItemDefaults = useEvent((item: any = undefined) => {","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-core/src/test-ui/SimpleFormIterator.tsx#L178-L214","documentation":"SimpleFormIterator is the default iterator body of <ArrayInput>. It derives its source from the surrounding input via useWrappedSource(''); if there is no wrapped source (i.e., it is not inside an iterator input like ArrayInput), it cannot know which array field to iterate and throws.","triggerScenarios":"Using <SimpleFormIterator> directly inside a <SimpleForm> without an <ArrayInput> parent; rendering it in a custom input that is not an iterator context; placing it inside ArrayInput's wrong slot that bypasses the Form iterator context (e.g. outside via useArrayInput failing later).","commonSituations":"Reusing SimpleFormIterator for display outside forms; copy-pasting form markup where ArrayInput was deleted; building custom array editors without the required parent input.","solutions":["Always nest it inside an input that provides the array context: <ArrayInput source=\"tags\"><SimpleFormIterator>...</SimpleFormIterator></ArrayInput>","If you need custom array UI outside ArrayInput, build it with useFieldArray from react-hook-form instead of reusing SimpleFormIterator","Ensure any wrapper component you create forwards children into ArrayInput rather than replacing it"],"exampleFix":"// before\n<SimpleForm>\n  <SimpleFormIterator>{...}</SimpleFormIterator>\n</SimpleForm>\n\n// after\n<SimpleForm>\n  <ArrayInput source=\"tags\">\n    <SimpleFormIterator>{...}</SimpleFormIterator>\n  </ArrayInput>\n</SimpleForm>","handlingStrategy":"validation","validationCode":"// Ensure ArrayInput is the parent before rendering the iterator\n<ArrayInput source=\"tags\">\n  {tags != null ? <SimpleFormIterator /> : null}\n</ArrayInput>","typeGuard":"const isInArrayInput = (children: React.ReactNode, ctx: React.Context<unknown>) =>\n  React.useContext(ctx) != null; // via useArrayInput's context in a wrapper component","tryCatchPattern":null,"preventionTips":["Never render SimpleFormIterator outside ArrayInput","Build custom array UIs on useFieldArray instead of reusing SimpleFormIterator","Keep ArrayInput and its iterator as an inseparable pair in shared components","Document the required parent in custom form component APIs"],"tags":["react-admin","array-input","missing-context","form"],"backgroundTag":"missing-iterator-context","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}