feat: adds req to filterOptions args (#10204)

Adds `req` to `filterOptions` arguments.
This commit is contained in:
James Mikrut
2024-12-27 16:38:14 -05:00
committed by GitHub
parent bb0c8a8c62
commit cf8c0ae959
5 changed files with 5 additions and 0 deletions

View File

@@ -156,6 +156,7 @@ called with an argument object with the following properties:
| `siblingData` | An object containing document data that is scoped to only fields within the same parent of this field |
| `id` | The `id` of the current document being edited. `id` is `undefined` during the `create` operation |
| `user` | An object containing the currently authenticated user |
| `req` | The Payload Request, which contains references to `payload`, `user`, `locale`, and more. |
## Example

View File

@@ -108,6 +108,7 @@ called with an argument object with the following properties:
| `siblingData` | An object containing document data that is scoped to only fields within the same parent of this field |
| `id` | The `id` of the current document being edited. `id` is `undefined` during the `create` operation |
| `user` | An object containing the currently authenticated user |
| `req` | The Payload Request, which contains references to `payload`, `user`, `locale`, and more. |
### Example#filter-options-example

View File

@@ -243,6 +243,7 @@ export type FilterOptionsProps<TData = any> = {
* The collection `slug` to filter against, limited to this field's `relationTo` property.
*/
relationTo: CollectionSlug
req: PayloadRequest
/**
* An object containing document data that is scoped to only fields within the same parent of this field.
*/

View File

@@ -525,6 +525,7 @@ const validateFilterOptions: Validate<
id,
data,
relationTo: collection,
req,
siblingData,
user,
})

View File

@@ -532,6 +532,7 @@ export const addFieldStatePromise = async (args: AddFieldStatePromiseArgs): Prom
id,
data: fullData,
relationTo: field.relationTo,
req,
siblingData: data,
user: req.user,
})