Skip to content

fix(plugin-multi-tenant): prevent form reset when tenant create fails validation#16990

Open
jhjh1214 wants to merge 1 commit into
payloadcms:mainfrom
jhjh1214:fix/multi-tenant-form-reset-on-validation
Open

fix(plugin-multi-tenant): prevent form reset when tenant create fails validation#16990
jhjh1214 wants to merge 1 commit into
payloadcms:mainfrom
jhjh1214:fix/multi-tenant-form-reset-on-validation

Conversation

@jhjh1214

Copy link
Copy Markdown

What?

When creating a document in the tenants collection, a client-side validation failure caused the entire form to wipe its values.

Why?

WatchTenantCollection watches submitted and calls syncTenants() whenever operation === 'create' && submitted. But submitted becomes true on any submit attempt — including failed validation — not only on a successful save. The resulting syncTenants() call triggered a state cascade that called router.refresh(), which reset the form to its empty initial state.

How?

Added an id guard to the effect:

if (operation === 'create' && submitted && id) {

Fixes #16953

@jhjh1214 jhjh1214 requested a review from JarrodMFlesch as a code owner June 13, 2026 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: multi-tenant tenants create form wiped on failed validation

1 participant