fix(plugin-multi-tenant): corrects default value for tenantsArrayTenantFieldName (#11189)

Incorrect default value on exported `tenantsArrayField` field. Should
have been `tenant` but was using `tenants`. This affected the
multi-tenant example which uses a custom tenants array field.

You would not notice this issue unless you were using:
```ts
tenantsArrayField: {
  includeDefaultField: false,
}
```

Fixes https://github.com/payloadcms/payload/issues/11125
This commit is contained in:
Jarrod Flesch
2025-02-14 10:55:19 -05:00
committed by GitHub
parent 480113a4fe
commit b65ae073d2
2 changed files with 31 additions and 4 deletions

View File

@@ -10,6 +10,9 @@ import { setCookieBasedOnDomain } from './hooks/setCookieBasedOnDomain'
import { tenantsArrayField } from '@payloadcms/plugin-multi-tenant/fields'
const defaultTenantArrayField = tenantsArrayField({
tenantsArrayFieldName: 'tenants',
tenantsArrayTenantFieldName: 'tenant',
tenantsCollectionSlug: 'tenants',
arrayFieldAccess: {},
tenantFieldAccess: {},
rowFields: [

View File

@@ -3,19 +3,43 @@ import type { ArrayField, RelationshipField } from 'payload'
import { defaults } from '../../defaults.js'
type Args = {
/**
* Access configuration for the array field
*/
arrayFieldAccess?: ArrayField['access']
/**
* Additional fields to include on the tenant array rows
*/
rowFields?: ArrayField['fields']
/**
* Access configuration for the tenant field
*/
tenantFieldAccess?: RelationshipField['access']
tenantsArrayFieldName: ArrayField['name']
tenantsArrayTenantFieldName: RelationshipField['name']
tenantsCollectionSlug: string
/**
* The name of the array field that holds the tenants
*
* @default 'tenants'
*/
tenantsArrayFieldName?: ArrayField['name']
/**
* The name of the field that will be used to store the tenant relationship in the array
*
* @default 'tenant'
*/
tenantsArrayTenantFieldName?: RelationshipField['name']
/**
* The slug for the tenant collection
*
* @default 'tenants'
*/
tenantsCollectionSlug?: string
}
export const tenantsArrayField = ({
arrayFieldAccess,
rowFields,
tenantFieldAccess,
tenantsArrayFieldName = defaults.tenantsArrayFieldName,
tenantsArrayTenantFieldName = defaults.tenantsArrayFieldName,
tenantsArrayTenantFieldName = defaults.tenantsArrayTenantFieldName,
tenantsCollectionSlug = defaults.tenantCollectionSlug,
}: Args): ArrayField => ({
name: tenantsArrayFieldName,