Skip to content

Commit

Permalink
feat: adds req to filterOptions args (#10204)
Browse files Browse the repository at this point in the history
Adds `req` to `filterOptions` arguments.
  • Loading branch information
jmikrut authored Dec 27, 2024
1 parent bb0c8a8 commit cf8c0ae
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/fields/relationship.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions docs/fields/upload.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions packages/payload/src/fields/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
1 change: 1 addition & 0 deletions packages/payload/src/fields/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ const validateFilterOptions: Validate<
id,
data,
relationTo: collection,
req,
siblingData,
user,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ export const addFieldStatePromise = async (args: AddFieldStatePromiseArgs): Prom
id,
data: fullData,
relationTo: field.relationTo,
req,
siblingData: data,
user: req.user,
})
Expand Down

0 comments on commit cf8c0ae

Please sign in to comment.