{"record":{"id":"f6c3c34fcb489cb8","repo":"marmelab/react-admin","slug":"if-you-re-not-wrapping-the-checkboxgroupinput-insi","errorCode":null,"errorMessage":"If you're not wrapping the CheckboxGroupInput inside a ReferenceArrayInput, you must provide the source prop","messagePattern":"If you're not wrapping the CheckboxGroupInput inside a ReferenceArrayInput, you must provide the source prop","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-ui-materialui/src/input/CheckboxGroupInput.tsx","lineNumber":167,"sourceCode":"\n    const {\n        allChoices,\n        isPending,\n        error: fetchError,\n        resource,\n        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 CheckboxGroupInput 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 CheckboxGroupInput inside a ReferenceArrayInput, you must provide the choices prop`\n        );\n    }\n\n    const {\n        field: { onChange: formOnChange, onBlur: formOnBlur, value, ref },\n        fieldState: { error, invalid },\n        id,\n        isRequired,\n    } = useInput({\n        format,\n        parse,","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-ui-materialui/src/input/CheckboxGroupInput.tsx#L149-L185","documentation":"CheckboxGroupInput uses useChoicesContext, which can receive source from a parent ReferenceArrayInput. When rendered standalone the source prop is mandatory because it identifies the form field; without it the component cannot bind to react-hook-form and throws during render.","triggerScenarios":"Rendering <CheckboxGroupInput /> without a source prop and without a ReferenceArrayInput parent that supplies one.","commonSituations":"Copy-pasting the component out of a ReferenceArrayInput example, renaming props, or conditionally spreading props so source becomes undefined.","solutions":["Add the source prop, e.g. <CheckboxGroupInput source=\"roles\" choices={[...]} />","Or wrap it in a <ReferenceArrayInput source=\"roles\" reference=\"roles\"> so source comes from context"],"exampleFix":"// before\n<CheckboxGroupInput choices={roleChoices} />\n// after\n<CheckboxGroupInput source=\"roles\" choices={roleChoices} />","handlingStrategy":"validation","validationCode":"if (source === undefined) {\n  throw new Error('CheckboxGroupInput requires a source prop (or a ReferenceArrayInput parent)');\n}","typeGuard":"const hasSource = (\n  p: CheckboxGroupInputProps\n): p is CheckboxGroupInputProps & { source: string } =>\n  typeof p.source === 'string' && p.source.length > 0;","tryCatchPattern":"try {\n  render(<CheckboxGroupInput {...props} />);\n} catch (e) {\n  if (e.message.includes('must provide the source prop')) {\n    console.error('CheckboxGroupInput misconfigured:', e.message);\n  }\n}","preventionTips":["Always pass source explicitly unless inside a ReferenceArrayInput","Avoid conditional spreads that can drop source (e.g. {...maybeProps})","Type the wrapper component to require source: { source: string }"],"tags":["react-admin","checkboxgroupinput","missing-prop"],"backgroundTag":"missing-required-prop","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}