From 5ab2820cf07a425050cb6d1c7ad9eff5f0672439 Mon Sep 17 00:00:00 2001 From: Swapnil M Mane Date: Wed, 3 Jul 2024 17:04:02 +0530 Subject: [PATCH] docs: added the details on creating a read-only text input field in headless cms --- .../headless-cms/extending/custom-field-type.mdx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/developer-docs/5.35.x/headless-cms/extending/custom-field-type.mdx b/docs/developer-docs/5.35.x/headless-cms/extending/custom-field-type.mdx index cc5b12b0b..97b9ac1f0 100644 --- a/docs/developer-docs/5.35.x/headless-cms/extending/custom-field-type.mdx +++ b/docs/developer-docs/5.35.x/headless-cms/extending/custom-field-type.mdx @@ -371,3 +371,17 @@ As discussed earlier, another optional plugin type is `CmsModelFieldToElasticsea It is similar to the `CmsModelFieldToStoragePlugin` plugin type, but works with Elasticsearch, so you can do the transformations before storing the data into the index, and after retrieving it. [Here](https://github.com/webiny/webiny-js/blob/731966ba13e6d9c5c82828a89e0e9ef7d4a0a27d/packages/api-headless-cms-ddb-es/src/elasticsearch/indexing/numberIndexing.ts) is an example of Field to Elasticsearch Plugin. For primitive data types fields, `isSearchable: true` flag will do the work for you for indexing. But if you have a complex field or want to store your field in a certain special way, you can create a plugin of `CmsModelFieldToElasticsearchPlugin` type. + +## FAQ + +### How to create a read-only text input field in Headless CMS? + +To create a read-only text input field in Webiny's Headless CMS, you need to create a [custom field type](/docs/{version}/headless-cms/extending/custom-field-type). +Webiny doesn't provide a read-only field out of the box because the requirements for such a field can vary greatly. Here are some ways users might populate this field: + +- Populate the field using life cycle events, for example: + - Populate on before create + - Populate on before update +- Dynamically calculate the field's output +- Populate the field from an external system but make it read-only within Webiny +By creating a custom field type, you can tailor the read-only field to meet your specific needs. \ No newline at end of file