Skip to content

Commit bf3b8cc

Browse files
committed
fix: Fix findField function for subfields (#13)
1 parent 804f3f3 commit bf3b8cc

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/dev/src/payload/collections/users.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ const Users: CollectionConfig = {
1212
}, */
1313
},
1414
fields: [
15+
{
16+
name: "name",
17+
type: "text",
18+
label: "Username", // Add label to name field
19+
},
1520
{
1621
name: "id",
1722
type: "text",

packages/payload-authjs/src/utils/payload.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ const findField = (fields: Field[], name: string): Field | undefined => {
8686
for (const field of fields) {
8787
if ("fields" in field && !fieldAffectsData(field)) {
8888
// Find in subfields if field not affecting data (e.g. row)
89-
return findField(field.fields, name);
89+
const found = findField(field.fields, name);
90+
if (found) {
91+
return found;
92+
}
9093
} else if (field.type === "tabs") {
9194
// For each tab, find the field
9295
for (const tab of field.tabs) {

0 commit comments

Comments
 (0)