Search the documentation
 Show GitHub edit links  Hide GitHub edit links
In OpenCms since: 9.5 Documented since: 9.5 Latest revision for: 9.5 Valid for OpenCms: 10.5.3

The value of one editor field or even the widget configuration can depend on the values of other editor fields. The dependencies are defined in the XSD defining the content. We show an example for dependent fields: We change a field's value depending on the value of another field.

The result

Edit the content, change the picture and see what happens to the value of CopyText.

Copyright notice: copyleft

Example resources and the interesting spots

The dependency between the field values is configured in the XSD that defines the content type.

<xsd:schema xmlns:xsd=""

	<xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd" />

	<xsd:element name="DocumentationDemoArticleDependentFields" type="OpenCmsDocumentationDemoArticleDependentFields" />

	<xsd:complexType name="OpenCmsDocumentationDemoArticleDependentFields">
			<xsd:element name="DocumentationDemoArticleDependentField" type="OpenCmsDocumentationDemoArticleDependentField"
				minOccurs="0" maxOccurs="unbounded" />

	<xsd:complexType name="OpenCmsDocumentationDemoArticleDependentField">
			<xsd:element name="Image" type="OpenCmsVfsFile" />
			<xsd:element name="CopyText" type="OpenCmsString" />
		<xsd:attribute name="language" type="OpenCmsLocale" use="required" />

				<layout element="Image" widget="ImageGalleryWidget" />
					scope="Image" configuration="Copyright|../CopyText" />

The interesting spot is the node <editorchangehandlers>. Here the dependencies are defined. Each sub-node <editorchangehandler> has three attributes:

Attributes of <editorchangehandler>

The class that handles the dependency. By default, OpenCms providesĀ CmsEditorChangeHandlerProperty as a concrete handler implementation, but you can write your own handlers.


Define the editor fields that should be observed for changes. The fields have to be specified by an XPath, e.g., "Paragraphs*/Headline". The path can contain * as wildcard to observe all elements in a sequence. Moreover, the path can also explicitly addess one element in a series and all fields of subcontent. For example, "Paragraphs[2]" would cause observation for all fields in the second paragraph.


Configuration is handler specific, hence it depends on the class you specified in the class attribute. For example, the CmsEditorChangeHandlerProperty takes a property name and the path to the field that should be updated with the property, where the two are separated by |. The path can be given relative to the observed field or absolute.

In the example, we use the CmsEditorChangeHandlerProperty to observe the Image editor field and copy the Copytext property of the resource given as the value of the Image field to the field CopyText. Whenever the value of Image changes, the value of CopyText will be updated.

Notice the following pecularities:

  • You can alter the CopyText value in the content editor and your alteration will be stored. Only if you change the Image value, your altered value will be replaced.
  • Altering the CopyText will not update the Copyright property of the image. If you want that, define a mapping from CopyText to the Copyright property.

You can improve this page

Please contribute your suggestions or comments regarding this topic on our wiki. For support questions, please use the OpenCms mailing list or go for professional support.