marmelab/react-admin · error · Error
If you're not wrapping the SelectInput inside a…
Error message
If you're not wrapping the SelectInput inside a ReferenceInput, you must provide the source prop
What it means
SelectInput resolves its choices via useChoicesContext, which works either standalone (with an explicit `source` and `choices`) or inside a ReferenceInput (which supplies context). When the component is not inside a ReferenceInput-providing context and `source` is undefined, it cannot bind to the form field, so it throws.
Solutions
- Add the source prop: <SelectInput source="status" choices={...} />.
- Or wrap it in <ReferenceInput source="..." reference="..."> so the context supplies the source.
- In custom wrappers, pass through the source prop explicitly and guard it before render.
Example fix
// before
<SelectInput choices={[{ id: 'a', name: 'A' }]} />
// after
<SelectInput source="status" choices={[{ id: 'a', name: 'A' }]} /> Defensive patterns
Strategy: validation
Validate before calling
if (!source) {
throw new Error('SelectInput outside a ReferenceInput requires a source prop');
} Type guard
const hasSource = (p: { source?: string }): p is { source: string } =>
typeof p.source === 'string' && p.source.length > 0; Prevention
- Always pass source to standalone SelectInput
- When wrapping SelectInput, forward source explicitly instead of relying on spreads
- Prefer wrapping in ReferenceInput when choices come from a related resource
When it happens
Trigger: Rendering a bare <SelectInput choices={...} /> with no source prop outside a ReferenceInput; destructuring/forgetting source in a custom wrapper that spreads props; using SelectInput inside a context that doesn't supply a record source.
Common situations: Building custom wrappers that accidentally drop the source prop; moving a SelectInput out of a ReferenceInput but forgetting it still relied on context; dynamic forms where source is computed and can be undefined.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- If you're not wrapping the SelectInput inside a…
- emptyValue being set to null or undefined is not supported…
- requires either a `render` prop or `children` prop
- Input components require either a source or a name prop.
- does not accept a validate prop. Set the validate prop on…
AI-assisted analysis of marmelab/react-admin@051f511bb0 (2026-08-30).
Data as JSON: /api/errors/f04d6d7c2c8e3bcb.
Report an issue: GitHub.
Appendix: source
Thrown at packages/ra-ui-materialui/src/input/SelectInput.tsx:175
const {
allChoices,
isPending,
error: fetchError,
source,
resource,
isFromReference,
} = useChoicesContext({
choices: choicesProp,
isLoading: isLoadingProp,
isFetching: isFetchingProp,
isPending: isPendingProp,
resource: resourceProp,
source: sourceProp,
});
if (source === undefined) {
throw new Error(
`If you're not wrapping the SelectInput inside a ReferenceInput, you must provide the source prop`
);
}
if (!isPending && !fetchError && allChoices === undefined) {
throw new Error(
`If you're not wrapping the SelectInput inside a ReferenceInput, you must provide the choices prop`
);
}
const getRecordRepresentation = useGetRecordRepresentation(resource);
const { getChoiceText, getChoiceValue, getDisableValue } = useChoices({
optionText:
optionText ??
(isFromReference ? getRecordRepresentation : undefined),
optionValue,
disableValue,
translateChoice: translateChoice ?? !isFromReference,View on GitHub (pinned to 051f511bb0)