Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: added the details on creating a read-only text input field in headless cms #686

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.