Form Fragments
Contents
Reuseable form definitions
Introduction
If you find yourself in need of repeating the exact same form pattern across different schemas, form fragments may be what you’re looking for.
This is a special kind of schema, containging only a single form. You may then include the form fragment into other schemas.
Usage
Like other schemas, Form fragments are defined in YAML.
The file with the form fragment schema must be placed in the folder cms/form-fragments/<name> and called <name>.yaml. For example, cms/form-fragments/link/link.yaml.
kind: "FormFragment"
title: "Call to action"
form:
- type: "TextLine"
name: "url"
label: "Link target"
occurrences:
min: 1
max: 1
- type: "TextLine"
name: "label"
label: "Link text"
occurrences:
min: 1
max: 1
- type: "CheckBox"
name: "new_window"
label: "Open in new window"
Below is an example of a simple content type that references the call to action form fragment above.
The form fragment fields will simply be included into the final content type schema.
kind: "ContentType"
title: "Using form fragments"
form:
- type: "TextLine"
name: "heading"
label: "Heading"
- include: "link"
Limitations
Form fragments are only supported for content schemas, and may not be used in other schema contexts such as identity providers and tasks.