{"record":{"id":"b847145e982f5b5f","repo":"marmelab/react-admin","slug":"if-you-re-not-wrapping-the-radiobuttongroupinput-i-b84714","errorCode":null,"errorMessage":"If you're not wrapping the RadioButtonGroupInput inside a ReferenceArrayInput, you must provide the choices prop","messagePattern":"If you're not wrapping the RadioButtonGroupInput inside a ReferenceArrayInput, you must provide the choices prop","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-ui-materialui/src/input/RadioButtonGroupInput.tsx","lineNumber":164,"sourceCode":"        source,\n        isFromReference,\n    } = useChoicesContext({\n        choices: choicesProp,\n        isFetching: isFetchingProp,\n        isLoading: isLoadingProp,\n        isPending: isPendingProp,\n        resource: resourceProp,\n        source: sourceProp,\n    });\n\n    if (source === undefined) {\n        throw new Error(\n            `If you're not wrapping the RadioButtonGroupInput inside a ReferenceArrayInput, you must provide the source prop`\n        );\n    }\n\n    if (!isPending && !fetchError && allChoices === undefined) {\n        throw new Error(\n            `If you're not wrapping the RadioButtonGroupInput inside a ReferenceArrayInput, you must provide the choices prop`\n        );\n    }\n\n    const { id, isRequired, fieldState, field } = useInput({\n        format,\n        onBlur,\n        onChange,\n        parse,\n        resource,\n        source,\n        validate,\n        disabled,\n        readOnly,\n        ...rest,\n    });\n\n    const getRecordRepresentation = useGetRecordRepresentation(resource);","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-ui-materialui/src/input/RadioButtonGroupInput.tsx#L146-L182","documentation":"RadioButtonGroupInput needs choices to render its radio options. If the component is not pending and there is no fetch error but the resolved choices (props or reference context) are still undefined, it throws instead of rendering nothing, to surface the misconfiguration explicitly.","triggerScenarios":"Standalone RadioButtonGroupInput with source but no choices prop; or a ReferenceInput parent whose resolved choices are undefined once loading finished without an error state.","commonSituations":"Forgetting the choices prop on a standalone input, custom data loading returning undefined instead of [], or a reference query resolving with undefined data while isPending is false.","solutions":["Pass a choices array: <RadioButtonGroupInput source=\"gender\" choices={[{id:'m',name:'Male'}]} />","Use a ReferenceInput so choices are loaded from the referenced resource","Default computed choices to [] to guarantee a defined array"],"exampleFix":"// before\n<RadioButtonGroupInput source=\"gender\" choices={maybeChoices} />\n// after\n<RadioButtonGroupInput source=\"gender\" choices={maybeChoices ?? []} />","handlingStrategy":"validation","validationCode":"if (!isPending && !fetchError && !Array.isArray(allChoices)) {\n  throw new Error('RadioButtonGroupInput requires a defined choices array');\n}","typeGuard":"const hasChoices = (\n  p: RadioButtonGroupInputProps\n): p is RadioButtonGroupInputProps & { choices: any[] } =>\n  Array.isArray(p.choices);","tryCatchPattern":"try {\n  render(<RadioButtonGroupInput source=\"gender\" choices={maybeChoices} />);\n} catch (e) {\n  if (e.message.includes('must provide the choices prop')) {\n    render(<RadioButtonGroupInput source=\"gender\" choices={[]} />);\n  }\n}","preventionTips":["Always pass a choices array (even empty) for standalone inputs","Default dynamic values: choices={data ?? []}","When using ReferenceInput, gate rendering on isLoading to avoid rendering with undefined choices"],"tags":["react-admin","radiobuttongroupinput","missing-prop"],"backgroundTag":"missing-required-prop","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}