diff --git a/docs/Fields.md b/docs/Fields.md
index f42b1c81862..e033f7f6a2a 100644
--- a/docs/Fields.md
+++ b/docs/Fields.md
@@ -520,11 +520,11 @@ You can also prevent `` from adding link to children by setting
```
-You can also use a custom `linkType` function to get a custom path for the children.
+You can also use a custom `linkType` function to get a custom path for the children. This function must accept sourceId and reference as arguments.
```jsx
// Custom path
- '/my/path'}>
+ `/my/path/to/${reference}/${sourceId}`}>
```
diff --git a/packages/ra-core/src/controller/field/useReference.ts b/packages/ra-core/src/controller/field/useReference.ts
index 08a245331c9..1f62c4981e1 100644
--- a/packages/ra-core/src/controller/field/useReference.ts
+++ b/packages/ra-core/src/controller/field/useReference.ts
@@ -7,7 +7,7 @@ import { crudGetManyAccumulate } from '../../actions';
import { linkToRecord } from '../../util';
import { Record, ReduxState } from '../../types';
-type linkTypeFunction = () => string;
+type linkTypeFunction = (record: Record, reference: string) => string;
interface Option {
allowEmpty?: boolean;
@@ -52,8 +52,7 @@ export interface UseReferenceProps {
* @param {Object} option
* @param {boolean} option.allowEmpty do we allow for no referenced record (default to false)
* @param {string} option.basePath basepath to current resource
- * @param {string | false | linkTypeFunction} option.linkType The type of the link toward the referenced record. 'edit', 'show' or
- * false for no link (default to edit). Alternatively a function that returns a string
+ * @param {string | false | linkTypeFunction} option.linkType The type of the link toward the referenced record. 'edit', 'show' or false for no link (default to edit). Alternatively a function that returns a string
* @param {Object} option.record The The current resource record
* @param {string} option.reference The linked resource name
* @param {string} option.resource The current resource name
@@ -84,7 +83,7 @@ export const useReference = ({
const resourceLinkPath = !linkType
? false
: typeof linkType === 'function'
- ? linkType()
+ ? linkType(record, reference)
: linkToRecord(rootPath, sourceId, linkType as string);
return {