OpenWGA 7.11 - WebTML reference
WebTML tags » input<tml:input relationtype ="normal | protected">
Purpose:
Description:
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.
Value(s):
Examples:
<tml:script>
categories = createList();
var child = context("children[0]");
while (child != null) {
categories.add(child.TITLE + "|" + child.KEY);
child = child.context("siblings[+1]", false);
}
</tml:script>
<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:
<tml:script>
categories = context("name:categories").content().getChildContents();
</tml:script>
<tml:input name="category" type="select" options="{ WGA.buildOptions(categories) }" relationtype="normal"/>