marmelab/react-admin · error · Error

If you're not wrapping the RadioButtonGroupInput inside a Re

Error message

If you're not wrapping the RadioButtonGroupInput inside a ReferenceArrayInput, you must provide the source prop

What it means

RadioButtonGroupInput resolves source and choices through useChoicesContext. Outside a ReferenceInput-like parent, source must be supplied explicitly so the component can register the field with the form; missing source means an unbindable input, so it throws at render time.

Source

Thrown at packages/ra-ui-materialui/src/input/RadioButtonGroupInput.tsx:158

    const {
        allChoices,
        isPending,
        error: fetchError,
        resource,
        source,
        isFromReference,
    } = useChoicesContext({
        choices: choicesProp,
        isFetching: isFetchingProp,
        isLoading: isLoadingProp,
        isPending: isPendingProp,
        resource: resourceProp,
        source: sourceProp,
    });

    if (source === undefined) {
        throw new Error(
            `If you're not wrapping the RadioButtonGroupInput inside a ReferenceArrayInput, you must provide the source prop`
        );
    }

    if (!isPending && !fetchError && allChoices === undefined) {
        throw new Error(
            `If you're not wrapping the RadioButtonGroupInput inside a ReferenceArrayInput, you must provide the choices prop`
        );
    }

    const { id, isRequired, fieldState, field } = useInput({
        format,
        onBlur,
        onChange,
        parse,
        resource,
        source,
        validate,

View on GitHub (pinned to 051f511bb0)

Solutions

  1. Add the source prop: <RadioButtonGroupInput source="gender" choices={[...]} />
  2. Or wrap it in a ReferenceInput that supplies the source via context

Example fix

// before
<RadioButtonGroupInput choices={genderChoices} />
// after
<RadioButtonGroupInput source="gender" choices={genderChoices} />
Defensive patterns

Strategy: validation

Validate before calling

if (source === undefined) {
  throw new Error('RadioButtonGroupInput requires a source prop (or a ReferenceInput parent)');
}

Type guard

const hasSource = (
  p: RadioButtonGroupInputProps
): p is RadioButtonGroupInputProps & { source: string } =>
  typeof p.source === 'string' && p.source.length > 0;

Try / catch

try {
  render(<RadioButtonGroupInput {...props} />);
} catch (e) {
  if (e.message.includes('must provide the source prop')) {
    console.error('RadioButtonGroupInput misconfigured:', e.message);
  }
}

Prevention

When it happens

Trigger: Rendering <RadioButtonGroupInput /> without a source prop and without a parent ReferenceInput providing one.

Common situations: Moving the input out of a ReferenceInput wrapper during a refactor, conditional prop spreading leaving source undefined, or a typo in the prop name (e.g. sources).

Related errors


AI-assisted analysis of marmelab/react-admin@051f511bb0 (2026-08-30). Data as JSON: /api/errors/8cbd4d29d1fa735f. Report an issue: GitHub.