{"record":{"id":"1e9c09e9b5686489","repo":"marmelab/react-admin","slug":"useapplyinputdefaultvalues-no-fieldarrayinputcont","errorCode":null,"errorMessage":"useApplyInputDefaultValues: No fieldArrayInputControl passed in props for array input usage","messagePattern":"useApplyInputDefaultValues: No fieldArrayInputControl passed in props for array input usage","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-core/src/form/useApplyInputDefaultValues.ts","lineNumber":87,"sourceCode":"        // Side note: For Array Input but checked for all to avoid possible regression\n        // Since we use get(record, source), if source is like foo.23.bar,\n        // this effect will run. However we only want to set the default value\n        // for the subfield bar if the record actually has a value for foo.23\n        const pathContainsIndex = finalSource\n            .split('.')\n            .some(pathPart => numericRegex.test(pathPart));\n        if (pathContainsIndex) {\n            const parentPath = finalSource.split('.').slice(0, -1).join('.');\n            const parentValue = get(getValues(), parentPath);\n            if (parentValue == null) {\n                // the parent is undefined, so we don't want to set the default value\n                return;\n            }\n        }\n\n        if (isArrayInput) {\n            if (!fieldArrayInputControl) {\n                throw new Error(\n                    'useApplyInputDefaultValues: No fieldArrayInputControl passed in props for array input usage'\n                );\n            }\n\n            // We need to update inputs nested in array using react hook forms\n            // own array controller rather then the generic reset to prevent control losing\n            // context of the nested inputs\n            fieldArrayInputControl.replace(defaultValue);\n            // resets the form so that control no longer sees the form as dirty after\n            // defaults applied\n            reset({}, { keepValues: true });\n\n            return;\n        }\n\n        resetField(finalSource, { defaultValue });\n    });\n};","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-core/src/form/useApplyInputDefaultValues.ts#L69-L105","documentation":"When an input is an array input (e.g. ArrayInput/SelectArrayInput), useApplyInputDefaultValues needs the fieldArrayInputControl prop to reset nested fields through react-hook-form's array controller. If the input is detected as an array input but no control was passed, it throws because defaults cannot be applied safely to nested array fields via a generic reset.","triggerScenarios":"Building a custom array input component that uses useInput (or wraps InputHelper) with isArrayInput logic but forgets to pass fieldArrayInputControl from useFieldArray; version upgrades where the prop became required.","commonSituations":"Custom ArrayInput-like components written against react-hook-form's useFieldArray; copying an older custom input example into a newer react-admin version where the contract changed.","solutions":["Pass the control from useFieldArray: const fieldArrayInputControl = useFieldArray({ control, name }); then include it in the props forwarded to the input.","If the input is not really an array input, fix the flags so isArrayInput is false.","Use react-admin's built-in ArrayInput instead of a custom one.","Check the react-admin changelog for the version where fieldArrayInputControl became required and update the custom component."],"exampleFix":"// before\nconst MyArrayInput = (props) => {\n    useInput({ ...props, isArrayInput: true }); // no fieldArrayInputControl\n};\n// after\nconst MyArrayInput = (props) => {\n    const control = useFormContext().control;\n    const { fields, append, remove } = useFieldArray({ control, name: props.source });\n    useInput({ ...props, isArrayInput: true, fieldArrayInputControl: { fields, append, remove } });\n};","handlingStrategy":"validation","validationCode":"if (isArrayInput && !fieldArrayInputControl) {\n    throw new Error('array inputs require fieldArrayInputControl from useFieldArray');\n}","typeGuard":"const hasArrayControl = (p: { fieldArrayInputControl?: unknown }):\n    p is { fieldArrayInputControl: NonNullable<typeof p.fieldArrayInputControl> } =>\n    p.fieldArrayInputControl != null;","tryCatchPattern":"try {\n    applyInputDefaults();\n} catch (e) {\n    if (e.message.includes('fieldArrayInputControl')) {\n        console.error('pass useFieldArray result into your custom array input props');\n    }\n}","preventionTips":["Always wire useFieldArray into custom array inputs.","Prefer built-in ArrayInput over hand-rolled ones.","Review the react-admin changelog when upgrading around custom inputs.","Type custom input props to require fieldArrayInputControl for array usage."],"tags":["react-admin","forms","react-hook-form","developer-error"],"backgroundTag":"missing-required-prop","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}