OpenWGA 5.4 - WebTML reference

WebTML tags

<tml:form>

Description :
Generates a form to let OpenWGA users input data.

This is the WebTML pendant of the HTML tag <form> which will actually create an HTML form on the page output. It and its input fields provide many additional functionalities like  automatic data binding, optional session persistence and validation.
Derived from: Attributes:
show inherited attributes ...
Name Value(s) Purpose
contentclass content-class Defines the content class of content documents to be created with this form data
cssclass CSS class Determines the CSS class that controls the rendering of the HTML form in the browser. The content of this attribute is copied directly to the "class" attribute of the HTML form tag.
cssstyle CSS-Styleinformationen Equivalent to the HTML attribute style.
defaultaction action id Defines a WebTML action which is  invoked when the WebTML form is submitted per normal browser submit.
editable false | true Determines if form data is only displayed or if it can be edited.
htmlinput true|false|ignore Specifies if a WebTML form should accept a normal HTML input field.
id ID of the form ID of the form. Mandatory attribute at tml:form.
mode edit|readonly|view defines the display mode of the WebTML form
onsubmit JavaScript code Inserts the given JavaScript code to the event "onsubmit" of the HTML form. This will get executed before sending the form, for example to perform input validations.
persist true|false Marks a form as "persistent". Persistent forms caching their values on the server side. This values are also available if the user changes  to pages which do not contain the form. Because of that this forms are there for collecting data above various requests in one session e.g. shopping baskets. A persistent form can be addressed and edited with the TMLScript command "this.tmlformByID(id)", even if it is not sent in the last request or was generated on the current page. There are only two cases persistent Forms get deleted - the method "reset" is triggered with TMLScript - The server session of the User gets lost.
source content | newcontent | profile | portlet | none data source of form data

Details:
<tml:form> generates HTML code in form of :

<form methode=post" id="myform" action="URL of current page">... </form>

In the body of <tml:form> you can define <tml:input> tags to define input fields.  These fields get automatically filled by the data of the current content document, the user profile or the portlet configuration depending on the attribute "source" . Or they are initialized empty and get their data from the OpenWGA user.

Different from HTML forms, WebTML forms will not always be saved if they were sent per submit to the server. Instead each submit, for example by a <tml:button>, may trigger a WebTML action that can do different things to the form, including saving its data.

The form data is represented by the TMLScript object TMLForm on the server side. The data contained on this object can be saved to the forms source document by using WebTML default action $store. Or you can use the TMLScript methods tmlform.storeInContent()tmlform.storeInPortlet() or tmlform.storeInProfile() to save it to different documents.

A form is uniquely identified on the users session by its ID. As your form data gets posted across the requests you may use differing form definitions with differing fields to display it (even undisplayed fields will be conserved on the form) as long as you use the same ID on the form tag.

You may also have multiple forms on the same page with differing IDs but note that HTTP is only capable of posting the data of one form at a time and that the data of non-persistent forms will get lost if it is not posted.
Examples:

The following WebTML form contains one input field "name". The content of the form gets saved in the user profile if  the inline action(defined by <tml:url>) is trigged.

<tml:form source="profile" id="myform">

    Name: <tml:input name="name"/>

    <a href="<tml:url type="action">this.tmlform.storeInProfile()</tml:url>">speichern</a>

</tml:form>

The following WebTML form is an example for a HTML upload. The uploaded file gets attached to a content document.
<tml:action id="save">
    this.tmlform.attach( this.content());
</tml:action>

<tml:form id="Upload">
    File Upload<br>
    <tml:input type="file" name="FileUpload"> size="80" </tml:input><br>
    <a href="<tml:url type="action" action="save"/>">Save in content document</a>
</tml:form>