From d91478cd24b54626d9b07cd3510669976196d1c8 Mon Sep 17 00:00:00 2001 From: Sasha <64744993+r1tsuu@users.noreply.github.com> Date: Fri, 18 Apr 2025 21:56:19 +0300 Subject: [PATCH] docs: virtual fields linking with relationship fields (#12145) Adds docs for these changes https://github.com/payloadcms/payload/pull/11805 --- docs/configuration/collections.mdx | 38 ++++++------- docs/fields/array.mdx | 44 +++++++-------- docs/fields/blocks.mdx | 40 +++++++------- docs/fields/checkbox.mdx | 34 ++++++------ docs/fields/code.mdx | 40 +++++++------- docs/fields/date.mdx | 36 ++++++------ docs/fields/email.mdx | 36 ++++++------ docs/fields/json.mdx | 38 ++++++------- docs/fields/number.mdx | 46 +++++++-------- docs/fields/point.mdx | 36 ++++++------ docs/fields/radio.mdx | 40 +++++++------- docs/fields/relationship.mdx | 89 +++++++++++++++++++++--------- docs/fields/rich-text.mdx | 34 ++++++------ docs/fields/select.mdx | 46 +++++++-------- docs/fields/tabs.mdx | 16 +++--- docs/fields/text.mdx | 46 +++++++-------- docs/fields/textarea.mdx | 40 +++++++------- docs/fields/upload.mdx | 52 ++++++++--------- docs/queries/sort.mdx | 2 +- 19 files changed, 396 insertions(+), 357 deletions(-) diff --git a/docs/configuration/collections.mdx b/docs/configuration/collections.mdx index bbea44a36..9dcebc92c 100644 --- a/docs/configuration/collections.mdx +++ b/docs/configuration/collections.mdx @@ -120,25 +120,25 @@ export const MyCollection: CollectionConfig = { The following options are available: -| Option | Description | -| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `group` | Text or localization object used to group Collection and Global links in the admin navigation. Set to `false` to hide the link from the navigation while keeping its routes accessible. | -| `hidden` | Set to true or a function, called with the current user, returning true to exclude this Collection from navigation and admin routing. | -| `hooks` | Admin-specific hooks for this Collection. [More details](../hooks/collections). | -| `useAsTitle` | Specify a top-level field to use for a document title throughout the Admin Panel. If no field is defined, the ID of the document is used as the title. A field with `virtual: true` cannot be used as the title. | -| `description` | Text to display below the Collection label in the List View to give editors more information. Alternatively, you can use the `admin.components.Description` to render a React component. [More details](#custom-components). | -| `defaultColumns` | Array of field names that correspond to which columns to show by default in this Collection's List View. | -| `disableCopyToLocale` | Disables the "Copy to Locale" button while editing documents within this Collection. Only applicable when localization is enabled. | -| `hideAPIURL` | Hides the "API URL" meta field while editing documents within this Collection. | -| `enableRichTextLink` | The [Rich Text](../fields/rich-text) field features a `Link` element which allows for users to automatically reference related documents within their rich text. Set to `true` by default. | -| `enableRichTextRelationship` | The [Rich Text](../fields/rich-text) field features a `Relationship` element which allows for users to automatically reference related documents within their rich text. Set to `true` by default. | -| `meta` | Page metadata overrides to apply to this Collection within the Admin Panel. [More details](../admin/metadata). | -| `preview` | Function to generate preview URLs within the Admin Panel that can point to your app. [More details](../admin/preview). | -| `livePreview` | Enable real-time editing for instant visual feedback of your front-end application. [More details](../live-preview/overview). | -| `components` | Swap in your own React components to be used within this Collection. [More details](#custom-components). | -| `listSearchableFields` | Specify which fields should be searched in the List search view. [More details](#list-searchable-fields). | -| `pagination` | Set pagination-specific options for this Collection. [More details](#pagination). | -| `baseListFilter` | You can define a default base filter for this collection's List view, which will be merged into any filters that the user performs. | +| Option | Description | +| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `group` | Text or localization object used to group Collection and Global links in the admin navigation. Set to `false` to hide the link from the navigation while keeping its routes accessible. | +| `hidden` | Set to true or a function, called with the current user, returning true to exclude this Collection from navigation and admin routing. | +| `hooks` | Admin-specific hooks for this Collection. [More details](../hooks/collections). | +| `useAsTitle` | Specify a top-level field to use for a document title throughout the Admin Panel. If no field is defined, the ID of the document is used as the title. A field with `virtual: true` cannot be used as the title, unless it's linked to a relationship'. | +| `description` | Text to display below the Collection label in the List View to give editors more information. Alternatively, you can use the `admin.components.Description` to render a React component. [More details](#custom-components). | +| `defaultColumns` | Array of field names that correspond to which columns to show by default in this Collection's List View. | +| `disableCopyToLocale` | Disables the "Copy to Locale" button while editing documents within this Collection. Only applicable when localization is enabled. | +| `hideAPIURL` | Hides the "API URL" meta field while editing documents within this Collection. | +| `enableRichTextLink` | The [Rich Text](../fields/rich-text) field features a `Link` element which allows for users to automatically reference related documents within their rich text. Set to `true` by default. | +| `enableRichTextRelationship` | The [Rich Text](../fields/rich-text) field features a `Relationship` element which allows for users to automatically reference related documents within their rich text. Set to `true` by default. | +| `meta` | Page metadata overrides to apply to this Collection within the Admin Panel. [More details](../admin/metadata). | +| `preview` | Function to generate preview URLs within the Admin Panel that can point to your app. [More details](../admin/preview). | +| `livePreview` | Enable real-time editing for instant visual feedback of your front-end application. [More details](../live-preview/overview). | +| `components` | Swap in your own React components to be used within this Collection. [More details](#custom-components). | +| `listSearchableFields` | Specify which fields should be searched in the List search view. [More details](#list-searchable-fields). | +| `pagination` | Set pagination-specific options for this Collection. [More details](#pagination). | +| `baseListFilter` | You can define a default base filter for this collection's List view, which will be merged into any filters that the user performs. | ### Custom Components diff --git a/docs/fields/array.mdx b/docs/fields/array.mdx index d85426cbd..a62a6a528 100644 --- a/docs/fields/array.mdx +++ b/docs/fields/array.mdx @@ -39,28 +39,28 @@ export const MyArrayField: Field = { ## Config Options -| Option | Description | -| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`label`** | Text used as the heading in the [Admin Panel](../admin/overview) or an object with keys for each language. Auto-generated from name if not defined. | -| **`fields`** \* | Array of field types to correspond to each row of the Array. | -| **`validate`** | Provide a custom validation function that will be executed on both the [Admin Panel](../admin/overview) and the backend. [More](/docs/fields/overview#validation) | -| **`minRows`** | A number for the fewest allowed items during validation when a value is present. | -| **`maxRows`** | A number for the most allowed items during validation when a value is present. | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide an array of row data to be used for this field's default value. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this Array will be kept, so there is no need to specify each nested field as `localized`. | -| **`required`** | Require this field to have a value. | -| **`labels`** | Customize the row labels appearing in the Admin dashboard. | -| **`admin`** | Admin-specific configuration. [More details](#admin-options). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). | -| **`dbName`** | Custom table name for the field when using SQL Database Adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`label`** | Text used as the heading in the [Admin Panel](../admin/overview) or an object with keys for each language. Auto-generated from name if not defined. | +| **`fields`** \* | Array of field types to correspond to each row of the Array. | +| **`validate`** | Provide a custom validation function that will be executed on both the [Admin Panel](../admin/overview) and the backend. [More](/docs/fields/overview#validation) | +| **`minRows`** | A number for the fewest allowed items during validation when a value is present. | +| **`maxRows`** | A number for the most allowed items during validation when a value is present. | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide an array of row data to be used for this field's default value. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this Array will be kept, so there is no need to specify each nested field as `localized`. | +| **`required`** | Require this field to have a value. | +| **`labels`** | Customize the row labels appearing in the Admin dashboard. | +| **`admin`** | Admin-specific configuration. [More details](#admin-options). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). | +| **`dbName`** | Custom table name for the field when using SQL Database Adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/blocks.mdx b/docs/fields/blocks.mdx index aa1b860c2..34410bb1d 100644 --- a/docs/fields/blocks.mdx +++ b/docs/fields/blocks.mdx @@ -39,26 +39,26 @@ export const MyBlocksField: Field = { ## Config Options -| Option | Description | -| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`label`** | Text used as the heading in the Admin Panel or an object with keys for each language. Auto-generated from name if not defined. | -| **`blocks`** \* | Array of [block configs](/docs/fields/blocks#block-configs) to be made available to this field. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | -| **`minRows`** | A number for the fewest allowed items during validation when a value is present. | -| **`maxRows`** | A number for the most allowed items during validation when a value is present. | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API response or the Admin Panel. | -| **`defaultValue`** | Provide an array of block data to be used for this field's default value. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this field will be kept, so there is no need to specify each nested field as `localized`. | -| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | -| **`labels`** | Customize the block row labels appearing in the Admin dashboard. | -| **`admin`** | Admin-specific configuration. [More details](#admin-options). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`label`** | Text used as the heading in the Admin Panel or an object with keys for each language. Auto-generated from name if not defined. | +| **`blocks`** \* | Array of [block configs](/docs/fields/blocks#block-configs) to be made available to this field. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | +| **`minRows`** | A number for the fewest allowed items during validation when a value is present. | +| **`maxRows`** | A number for the most allowed items during validation when a value is present. | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API response or the Admin Panel. | +| **`defaultValue`** | Provide an array of block data to be used for this field's default value. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this field will be kept, so there is no need to specify each nested field as `localized`. | +| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | +| **`labels`** | Customize the block row labels appearing in the Admin dashboard. | +| **`admin`** | Admin-specific configuration. [More details](#admin-options). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/checkbox.mdx b/docs/fields/checkbox.mdx index bb256fcca..c135b54b4 100644 --- a/docs/fields/checkbox.mdx +++ b/docs/fields/checkbox.mdx @@ -28,23 +28,23 @@ export const MyCheckboxField: Field = { ## Config Options -| Option | Description | -| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | -| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide data to be used for this field's default value, will default to false if field is also `required`. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. [More details](./overview#admin-options). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | +| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide data to be used for this field's default value, will default to false if field is also `required`. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. [More details](./overview#admin-options). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/code.mdx b/docs/fields/code.mdx index 26cc9abb3..e7fe52045 100644 --- a/docs/fields/code.mdx +++ b/docs/fields/code.mdx @@ -29,26 +29,26 @@ export const MyBlocksField: Field = { ## Config Options -| Option | Description | -| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | -| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | -| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | -| **`minLength`** | Used by the default validation function to ensure values are of a minimum character length. | -| **`maxLength`** | Used by the default validation function to ensure values are of a maximum character length. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-options). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | +| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | +| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | +| **`minLength`** | Used by the default validation function to ensure values are of a minimum character length. | +| **`maxLength`** | Used by the default validation function to ensure values are of a maximum character length. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-options). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/date.mdx b/docs/fields/date.mdx index de939f53a..e2a9d2ba0 100644 --- a/docs/fields/date.mdx +++ b/docs/fields/date.mdx @@ -28,24 +28,24 @@ export const MyDateField: Field = { ## Config Options -| Option | Description | -| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | -| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. [More details](#admin-options). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`timezone`** \* | Set to `true` to enable timezone selection on this field. [More details](#timezones). | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | +| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. [More details](#admin-options). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`timezone`** \* | Set to `true` to enable timezone selection on this field. [More details](#timezones). | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/email.mdx b/docs/fields/email.mdx index befa1019f..a40938617 100644 --- a/docs/fields/email.mdx +++ b/docs/fields/email.mdx @@ -28,24 +28,24 @@ export const MyEmailField: Field = { ## Config Options -| Option | Description | -| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | -| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | -| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. [More details](#admin-options). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | +| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | +| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. [More details](#admin-options). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/json.mdx b/docs/fields/json.mdx index 23d443ea3..5d18735c2 100644 --- a/docs/fields/json.mdx +++ b/docs/fields/json.mdx @@ -29,25 +29,25 @@ export const MyJSONField: Field = { ## Config Options -| Option | Description | -| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | -| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | -| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | -| **`jsonSchema`** | Provide a JSON schema that will be used for validation. [JSON schemas](https://json-schema.org/learn/getting-started-step-by-step) | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. [More details](#admin-options). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | +| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | +| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | +| **`jsonSchema`** | Provide a JSON schema that will be used for validation. [JSON schemas](https://json-schema.org/learn/getting-started-step-by-step) | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. [More details](#admin-options). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/number.mdx b/docs/fields/number.mdx index 49cb8bf63..a69d78fb8 100644 --- a/docs/fields/number.mdx +++ b/docs/fields/number.mdx @@ -28,29 +28,29 @@ export const MyNumberField: Field = { ## Config Options -| Option | Description | -| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | -| **`min`** | Minimum value accepted. Used in the default `validation` function. | -| **`max`** | Maximum value accepted. Used in the default `validation` function. | -| **`hasMany`** | Makes this field an ordered array of numbers instead of just a single number. | -| **`minRows`** | Minimum number of numbers in the numbers array, if `hasMany` is set to true. | -| **`maxRows`** | Maximum number of numbers in the numbers array, if `hasMany` is set to true. | -| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | -| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. [More details](#admin-options). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | +| **`min`** | Minimum value accepted. Used in the default `validation` function. | +| **`max`** | Maximum value accepted. Used in the default `validation` function. | +| **`hasMany`** | Makes this field an ordered array of numbers instead of just a single number. | +| **`minRows`** | Minimum number of numbers in the numbers array, if `hasMany` is set to true. | +| **`maxRows`** | Maximum number of numbers in the numbers array, if `hasMany` is set to true. | +| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | +| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. [More details](#admin-options). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/point.mdx b/docs/fields/point.mdx index 7c8e39f71..5a2c2e575 100644 --- a/docs/fields/point.mdx +++ b/docs/fields/point.mdx @@ -32,24 +32,24 @@ export const MyPointField: Field = { ## Config -| Option | Description | -| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`label`** | Used as a field label in the Admin Panel and to name the generated GraphQL type. | -| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | -| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. To support location queries, point index defaults to `2dsphere`, to disable the index set to `false`. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. [More details](./overview#admin-options). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`label`** | Used as a field label in the Admin Panel and to name the generated GraphQL type. | +| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | +| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. To support location queries, point index defaults to `2dsphere`, to disable the index set to `false`. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. [More details](./overview#admin-options). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/radio.mdx b/docs/fields/radio.mdx index 385f20abf..4ca69d7ab 100644 --- a/docs/fields/radio.mdx +++ b/docs/fields/radio.mdx @@ -33,26 +33,26 @@ export const MyRadioField: Field = { ## Config Options -| Option | Description | -| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`options`** \* | Array of options to allow the field to store. Can either be an array of strings, or an array of objects containing an `label` string and a `value` string. | -| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | -| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide data to be used for this field's default value. The default value must exist within provided values in `options`. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. [More details](#admin-options). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`enumName`** | Custom enum name for this field when using SQL Database Adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. | -| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`options`** \* | Array of options to allow the field to store. Can either be an array of strings, or an array of objects containing an `label` string and a `value` string. | +| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | +| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide data to be used for this field's default value. The default value must exist within provided values in `options`. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. [More details](#admin-options). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`enumName`** | Custom enum name for this field when using SQL Database Adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. | +| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/relationship.mdx b/docs/fields/relationship.mdx index e6c4faf81..10d652a2c 100644 --- a/docs/fields/relationship.mdx +++ b/docs/fields/relationship.mdx @@ -37,31 +37,31 @@ export const MyRelationshipField: Field = { ## Config Options -| Option | Description | -| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`relationTo`** \* | Provide one or many collection `slug`s to be able to assign relationships to. | -| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-relationship-options). | -| **`hasMany`** | Boolean when, if set to `true`, allows this field to have many relations instead of only one. | -| **`minRows`** | A number for the fewest allowed items during validation when a value is present. Used with `hasMany`. | -| **`maxRows`** | A number for the most allowed items during validation when a value is present. Used with `hasMany`. | -| **`maxDepth`** | Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached. [Max Depth](/docs/queries/depth#max-depth) | -| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | -| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | -| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. [More details](#admin-options). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | -| **`graphQL`** | Custom graphQL configuration for the field. [More details](/docs/graphql/overview#field-complexity) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`relationTo`** \* | Provide one or many collection `slug`s to be able to assign relationships to. | +| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-relationship-options). | +| **`hasMany`** | Boolean when, if set to `true`, allows this field to have many relations instead of only one. | +| **`minRows`** | A number for the fewest allowed items during validation when a value is present. Used with `hasMany`. | +| **`maxRows`** | A number for the most allowed items during validation when a value is present. Used with `hasMany`. | +| **`maxDepth`** | Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached. [Max Depth](/docs/queries/depth#max-depth) | +| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | +| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | +| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. [More details](#admin-options). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| **`graphQL`** | Custom graphQL configuration for the field. [More details](/docs/graphql/overview#field-complexity) | _\* An asterisk denotes that a property is required._ @@ -376,6 +376,45 @@ non-polymorphic relationship. +### Linking virtual fields with relationships + +You can link virtual fields to fields in other collections through a relationship (or upload) field, for example: + +```ts +{ + collections: [ + { + slug: 'categories', + fields: [ + { + name: 'title', + type: 'text', + }, + ], + }, + { + slug: 'posts', + fields: [ + { + type: 'relationship', + name: 'category', + relationTo: 'categories', + }, + { + type: 'text', + name: 'categoryTitle', + virtual: 'category.title', + }, + ], + }, + ], +} +``` + +Here, `categoryTitle` will _always_ be populated with the corresponding value, even if the current `depth` is `0`, You can also query and sort by this field. +The relationship must not be `hasMany: true` or polymorphic. +The path can be deeply nested into 2 or more relationship fields, for example `post.category.title` as long as all the relationship fields meet the above requirement. + ## Custom Components ### Field diff --git a/docs/fields/rich-text.mdx b/docs/fields/rich-text.mdx index 4e9cc8fe6..78c81917e 100644 --- a/docs/fields/rich-text.mdx +++ b/docs/fields/rich-text.mdx @@ -21,23 +21,23 @@ Instead, you can invest your time and effort into learning the underlying open-s ## Config Options -| Option | Description | -| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](./overview#field-names) | -| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](./overview#validation) | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](../authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide data to be used for this field's default value. [More](./overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](../configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. [More details](#admin-options). | -| **`editor`** | Customize or override the rich text editor. [More details](../rich-text/overview). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](./overview#field-names) | +| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](./overview#validation) | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](../authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide data to be used for this field's default value. [More](./overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](../configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. [More details](#admin-options). | +| **`editor`** | Customize or override the rich text editor. [More details](../rich-text/overview). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | \*_ An asterisk denotes that a property is required._ diff --git a/docs/fields/select.mdx b/docs/fields/select.mdx index 2c5384798..c8328a8d8 100644 --- a/docs/fields/select.mdx +++ b/docs/fields/select.mdx @@ -33,29 +33,29 @@ export const MySelectField: Field = { ## Config Options -| Option | Description | -| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`options`** \* | Array of options to allow the field to store. Can either be an array of strings, or an array of objects containing a `label` string and a `value` string. | -| **`hasMany`** | Boolean when, if set to `true`, allows this field to have many selections instead of only one. | -| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | -| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | -| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-options) for more details. | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`enumName`** | Custom enum name for this field when using SQL Database Adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. | -| **`dbName`** | Custom table name (if `hasMany` set to `true`) for this field when using SQL Database Adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. | -| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`options`** \* | Array of options to allow the field to store. Can either be an array of strings, or an array of objects containing a `label` string and a `value` string. | +| **`hasMany`** | Boolean when, if set to `true`, allows this field to have many selections instead of only one. | +| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | +| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | +| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-options) for more details. | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`enumName`** | Custom enum name for this field when using SQL Database Adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. | +| **`dbName`** | Custom table name (if `hasMany` set to `true`) for this field when using SQL Database Adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. | +| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/tabs.mdx b/docs/fields/tabs.mdx index cdbb01620..5e603dd8c 100644 --- a/docs/fields/tabs.mdx +++ b/docs/fields/tabs.mdx @@ -43,14 +43,14 @@ export const MyTabsField: Field = { Each tab must have either a `name` or `label` and the required `fields` array. You can also optionally pass a `description` to render within each individual tab. -| Option | Description | -| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| **`name`** | Groups field data into an object when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`label`** | The label to render on the tab itself. Required when name is undefined, defaults to name converted to words. | -| **`fields`** \* | The fields to render within this tab. | -| **`description`** | Optionally render a description within this tab to describe the contents of the tab itself. | -| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). (`name` must be present) | -| **`virtual`** | Provide `true` to disable field in the database (`name` must be present). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** | Groups field data into an object when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`label`** | The label to render on the tab itself. Required when name is undefined, defaults to name converted to words. | +| **`fields`** \* | The fields to render within this tab. | +| **`description`** | Optionally render a description within this tab to describe the contents of the tab itself. | +| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). (`name` must be present) | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/text.mdx b/docs/fields/text.mdx index 18d52809d..e19df883b 100644 --- a/docs/fields/text.mdx +++ b/docs/fields/text.mdx @@ -28,29 +28,29 @@ export const MyTextField: Field = { ## Config Options -| Option | Description | -| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | -| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | -| **`minLength`** | Used by the default validation function to ensure values are of a minimum character length. | -| **`maxLength`** | Used by the default validation function to ensure values are of a maximum character length. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | -| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. [More details](#admin-options). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`hasMany`** | Makes this field an ordered array of text instead of just a single text. | -| **`minRows`** | Minimum number of texts in the array, if `hasMany` is set to true. | -| **`maxRows`** | Maximum number of texts in the array, if `hasMany` is set to true. | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | +| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | +| **`minLength`** | Used by the default validation function to ensure values are of a minimum character length. | +| **`maxLength`** | Used by the default validation function to ensure values are of a maximum character length. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | +| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. [More details](#admin-options). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`hasMany`** | Makes this field an ordered array of text instead of just a single text. | +| **`minRows`** | Minimum number of texts in the array, if `hasMany` is set to true. | +| **`maxRows`** | Maximum number of texts in the array, if `hasMany` is set to true. | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/textarea.mdx b/docs/fields/textarea.mdx index e9754cd9b..264749607 100644 --- a/docs/fields/textarea.mdx +++ b/docs/fields/textarea.mdx @@ -28,26 +28,26 @@ export const MyTextareaField: Field = { ## Config Options -| Option | Description | -| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | -| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | -| **`minLength`** | Used by the default validation function to ensure values are of a minimum character length. | -| **`maxLength`** | Used by the default validation function to ensure values are of a maximum character length. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | -| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. [More details](#admin-options). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | +| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | +| **`minLength`** | Used by the default validation function to ensure values are of a minimum character length. | +| **`maxLength`** | Used by the default validation function to ensure values are of a maximum character length. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | +| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. [More details](#admin-options). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/upload.mdx b/docs/fields/upload.mdx index f8aefb4e5..2370c5549 100644 --- a/docs/fields/upload.mdx +++ b/docs/fields/upload.mdx @@ -44,32 +44,32 @@ export const MyUploadField: Field = { ## Config Options -| Option | Description | -| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`relationTo`** \* | Provide a single collection `slug` to allow this field to accept a relation to. **Note: the related collection must be configured to support Uploads.** | -| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-upload-options). | -| **`hasMany`** | Boolean which, if set to true, allows this field to have many relations instead of only one. | -| **`minRows`** | A number for the fewest allowed items during validation when a value is present. Used with hasMany. | -| **`maxRows`** | A number for the most allowed items during validation when a value is present. Used with hasMany. | -| **`maxDepth`** | Sets a number limit on iterations of related documents to populate when queried. [Depth](../queries/depth) | -| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | -| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | -| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | -| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | -| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | -| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | -| **`displayPreview`** | Enable displaying preview of the uploaded file. Overrides related Collection's `displayPreview` option. [More](/docs/upload/overview#collection-upload-options). | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. [Admin Options](./overview#admin-options). | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | -| **`typescriptSchema`** | Override field type generation with providing a JSON schema | -| **`virtual`** | Provide `true` to disable field in the database. See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | -| **`graphQL`** | Custom graphQL configuration for the field. [More details](/docs/graphql/overview#field-complexity) | +| Option | Description | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`relationTo`** \* | Provide a single collection `slug` to allow this field to accept a relation to. **Note: the related collection must be configured to support Uploads.** | +| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-upload-options). | +| **`hasMany`** | Boolean which, if set to true, allows this field to have many relations instead of only one. | +| **`minRows`** | A number for the fewest allowed items during validation when a value is present. Used with hasMany. | +| **`maxRows`** | A number for the most allowed items during validation when a value is present. Used with hasMany. | +| **`maxDepth`** | Sets a number limit on iterations of related documents to populate when queried. [Depth](../queries/depth) | +| **`label`** | Text used as a field label in the Admin Panel or an object with keys for each language. | +| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin Panel and the backend. [More](/docs/fields/overview#validation) | +| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/overview), include its data in the user JWT. | +| **`hooks`** | Provide Field Hooks to control logic for this field. [More details](../hooks/fields). | +| **`access`** | Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin Panel. | +| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | +| **`displayPreview`** | Enable displaying preview of the uploaded file. Overrides related Collection's `displayPreview` option. [More](/docs/upload/overview#collection-upload-options). | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. [Admin Options](./overview#admin-options). | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`typescriptSchema`** | Override field type generation with providing a JSON schema | +| **`virtual`** | Provide `true` to disable field in the database, or provide a string path to [link the field with a relationship](/docs/fields/relationship#linking-virtual-fields-with-relationships). See [Virtual Fields](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) | +| **`graphQL`** | Custom graphQL configuration for the field. [More details](/docs/graphql/overview#field-complexity) | _\* An asterisk denotes that a property is required._ diff --git a/docs/queries/sort.mdx b/docs/queries/sort.mdx index 01ecfc076..d9f46b2f9 100644 --- a/docs/queries/sort.mdx +++ b/docs/queries/sort.mdx @@ -8,7 +8,7 @@ keywords: query, documents, pagination, documentation, Content Management System Documents in Payload can be easily sorted by a specific [Field](../fields/overview). When querying Documents, you can pass the name of any top-level field, and the response will sort the Documents by that field in _ascending_ order. If prefixed with a minus symbol ("-"), they will be sorted in _descending_ order. In Local API multiple fields can be specified by using an array of strings. In REST API multiple fields can be specified by separating fields with comma. The minus symbol can be in front of individual fields. -Because sorting is handled by the database, the field cannot be a [Virtual Field](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges). It must be stored in the database to be searchable. +Because sorting is handled by the database, the field cannot be a [Virtual Field](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges) unless it's [linked with a relationship field](/docs/fields/relationship#linking-virtual-fields-with-relationships). It must be stored in the database to be searchable. **Tip:** For performance reasons, it is recommended to enable `index: true`