payloadcms / payloadcms/payload

`useAsTitle` virtual field validation is skipped if collection has auth enabled

Open
#16,142 1 comment 0 reactions 1 assignee View on GitHub

@PatrikKozak is already working on this.

Since Apr 15, 2026.

area: core created-by: Contributor
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Describe the Bug

I have virtual field name on users which was joining first and last name. Using it as title works, but searching for users inside relationship fields is broken this way, because virtual field cannot be queried inside where query .

When i searched how to fix this, where this issue was coming from, i encountered that suppossedly you can't use virtual field in useAsTitle. But i was wondering, why i didn't got any validation errors, it was clearly working. And then i found this -> https://github.com/payloadcms/payload/blob/main/packages/payload/src/collections/config/useAsTitle.ts#L35

This validation for virtual field is skipped if collection is auth-enabled.

Link to the code that reproduces this issue

https://github.com/VeiaG/payload-3-reproductions/tree/relationship-repro

Reproduction Steps

I don't think reproduction is needed here, because mistake is clear. But, you can clone reproduction repository, and try to start it -> The field "name" specified in "admin.useAsTitle" in the collection "test-collection" is virtual. A virtual field can be used as the title only when linked to a relationship field.

But, if you remove useAsTitle in test collection, everything works (excpet searching inside relatioship fields). But it should throw error too, because auth collection users has same useAsTitle logic as test collection

Which area(s) are affected?

area: core

Environment Info
Binaries:
  Node: 22.16.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.19.0
Relevant Packages:
  payload: 3.81.0
  next: 15.4.7
  @payloadcms/db-sqlite: 3.81.0
  @payloadcms/drizzle: 3.81.0
  @payloadcms/email-nodemailer: 3.81.0
  @payloadcms/graphql: 3.81.0
  @payloadcms/live-preview: 3.81.0
  @payloadcms/live-preview-react: 3.81.0
  @payloadcms/next/utilities: 3.81.0
  @payloadcms/payload-cloud: 3.81.0
  @payloadcms/plugin-nested-docs: 3.81.0
  @payloadcms/richtext-lexical: 3.81.0
  @payloadcms/translations: 3.81.0
  @payloadcms/ui/shared: 3.81.0
  react: 19.2.0
  react-dom: 19.2.0
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:40 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.