OpenWGA 7.6 - WebTML reference

WebTML tags » input

<tml:input relationtype ="normal | protected">


Lets <tml:input> store relations instead of items


When an <tml:input> field contains an attribute relationtype it is marked to store a relation rather than an item. It expects the value of the field to be the key of a page that should become the target of the relation (more concise: Target of the relation will be the released content document on this page which has the same language like the content that the relation is stored on).

The relation to this document is automatically created when the form gets stored by some high-level functionality:

The value of this attribute determines the type of relation. A protected relation differs from a normal relation in that it protects the relation target from being deleted.

The type of input fields determines if the input is stored as a single relation or as a relation group. If the type stores single values then a single relation of the input name is created/updated. If it can store multiple values then a relation group of the input name is stored containing individual relations to the targets.

An easy way to create options for an input that stores relations is using TMLScript method WGA.buildOptions() which takes a list of WGAPI content objects as option targets.

If HDBModel is used and the name of the input equals the name of a defined relation for the content to create/update then WebTML will automatically retrieve options based on the allowed target documents for this relation. You simply need to omit attributes options and optionsitem in that case.


normal: Creates a normal content relation

protected: Creates a protected content relation meaning that the target document is protected from deletion or archiving


A simple example where a script creates a list to feed a <tml:input type="select"> with contents to select. It therefor iterates over the children of the current context and adds an entry for each child. The entry contains the title of the child as display value and the content key as storage value. The resulting list is then passed to a <tml:input> which display it as selectable values. The selected content will be the target of  a relation named "category" that is created when a content storage function is called for the form.

categories = createList();
var child = context("children[0]");
while (child != null) {
  categories.add(child.TITLE + "|" + child.KEY);
  child = child.context("siblings[+1]", false);
<tml:input name="category" type="select" optionsitem="categories" relationtype="normal"/>

Another example using WGA.buildOptions(). Here we do not need to format the options ourselves but only collect the contents that should be available as options. This is more appropriate if we already use functionality that retrieves a list of contents, like some WGAPI methods do:

categories = context("name:categories").content().getChildContents();

<tml:input name="category" type="select" options="{ WGA.buildOptions(categories) }" relationtype="normal"/>