Skip to content

Commit d9c0c43

Browse files
authored
fix(ui): passes value to server component args (#12352)
### What? Allows the field value (if defined) to be accessed from `args` with custom server components. ### Why? Documentation states that the user can access `args.value` to get the value of the field at time of render (if a value is defined) when using a custom server component - however this isn't currently setup. <img width="469" alt="Screenshot 2025-05-08 at 4 51 30 PM" src="https://github.com/user-attachments/assets/9c167f80-5c5e-4fea-a31c-166281d9f7db" /> Link to docs [here](https://payloadcms.com/docs/fields/overview#default-props). ### How? Passes the value from `data` if it exists (does not exist for all field types) and adds `value` to the server component types as an optional property. Fixes #10389
1 parent a9cc747 commit d9c0c43

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

packages/payload/src/admin/forms/Field.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export type ServerComponentProps = {
9191
req: PayloadRequest
9292
siblingData: Data
9393
user: User
94+
value?: unknown
9495
}
9596

9697
export type ClientFieldBase<

packages/ui/src/forms/fieldSchemasToFormState/renderField.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export const renderField: RenderFieldMethod = ({
100100
req,
101101
siblingData,
102102
user: req.user,
103+
value: 'name' in fieldConfig && data?.[fieldConfig.name],
103104
}
104105

105106
switch (fieldConfig.type) {

0 commit comments

Comments
 (0)