marmelab/react-admin · error · Error
useApplyInputDefaultValues: No fieldArrayInputControl passed
Error message
useApplyInputDefaultValues: No fieldArrayInputControl passed in props for array input usage
What it means
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.
Source
Thrown at packages/ra-core/src/form/useApplyInputDefaultValues.ts:87
// Side note: For Array Input but checked for all to avoid possible regression
// Since we use get(record, source), if source is like foo.23.bar,
// this effect will run. However we only want to set the default value
// for the subfield bar if the record actually has a value for foo.23
const pathContainsIndex = finalSource
.split('.')
.some(pathPart => numericRegex.test(pathPart));
if (pathContainsIndex) {
const parentPath = finalSource.split('.').slice(0, -1).join('.');
const parentValue = get(getValues(), parentPath);
if (parentValue == null) {
// the parent is undefined, so we don't want to set the default value
return;
}
}
if (isArrayInput) {
if (!fieldArrayInputControl) {
throw new Error(
'useApplyInputDefaultValues: No fieldArrayInputControl passed in props for array input usage'
);
}
// We need to update inputs nested in array using react hook forms
// own array controller rather then the generic reset to prevent control losing
// context of the nested inputs
fieldArrayInputControl.replace(defaultValue);
// resets the form so that control no longer sees the form as dirty after
// defaults applied
reset({}, { keepValues: true });
return;
}
resetField(finalSource, { defaultValue });
});
};View on GitHub (pinned to 051f511bb0)
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.
Example fix
// before
const MyArrayInput = (props) => {
useInput({ ...props, isArrayInput: true }); // no fieldArrayInputControl
};
// after
const MyArrayInput = (props) => {
const control = useFormContext().control;
const { fields, append, remove } = useFieldArray({ control, name: props.source });
useInput({ ...props, isArrayInput: true, fieldArrayInputControl: { fields, append, remove } });
}; Defensive patterns
Strategy: validation
Validate before calling
if (isArrayInput && !fieldArrayInputControl) {
throw new Error('array inputs require fieldArrayInputControl from useFieldArray');
} Type guard
const hasArrayControl = (p: { fieldArrayInputControl?: unknown }):
p is { fieldArrayInputControl: NonNullable<typeof p.fieldArrayInputControl> } =>
p.fieldArrayInputControl != null; Try / catch
try {
applyInputDefaults();
} catch (e) {
if (e.message.includes('fieldArrayInputControl')) {
console.error('pass useFieldArray result into your custom array input props');
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- useUpdateMany mutation requires an array of ids
- useUpdateMany mutation requires a non-empty data object
- useUnique: missing resource prop or context
- emptyValue being set to null or undefined is not supported.
- Deprecated. FormTab now wrap their content inside a FormGrou
AI-assisted analysis of marmelab/react-admin@051f511bb0 (2026-08-30).
Data as JSON: /api/errors/1e9c09e9b5686489.
Report an issue: GitHub.