The control types supported by the form extension are:
| • | button - push button |
| • | text - allows typing in a text using the keyboard; can be one-line or multiline |
| • | checkbox - toggle (on / off) button |
| • | radiobutton - toggle (on / off) button, contained in a group, that allows the user to choose exactly one of a predefined set of options |
| • | submit - a special kind of button which submits the form controls data |
An xf:form contains one of more xf:form-control elements. Both form and form-control elements can be nested inside fo:block and fo:inline elements.
To create a form use:
<xf:form>
<!--Button-->
<xf:form-control name="ButtonName" type="button" value="ButtonText">
<!--One or more actions-->
<xf:form-action action-type="JavaScript" event="Event" annotation-reference="AnnotationId">
...
</xf:form-control>
<!--Text edit-->
<xf:form-control name="TextEditName" type="text" multiline="true | false" value="DefaultText">
<!--One or more actions-->
<xf:form-action action-type="JavaScript" event="Event" annotation-reference="AnnotationId">
...
</xf:form-control>
<!--Checkbox, initially checked-->
<xf:form-control name="CheckBoxName" type="checkbox" checked="true | false" value="ValueToSubmitWhenChecked">
<!--One or more actions-->
<xf:form-action action-type="JavaScript" event="Event" annotation-reference="AnnotationId">
...
</xf:form-control>
<!--Radio button group-->
<xf:form-control name="RadioGroup" type="radiobutton" checked="true | false" value="ValueToSubmitWhenSelected">
<!--One or more actions-->
<xf:form-action action-type="JavaScript" event="Event" annotation-reference="AnnotationId">
...
</xf:form-control>
<xf:form-control name="RadioGroup" type="radiobutton" checked="true | false" value="ValueToSubmitWhenSelected">
<!--One or more actions-->
<xf:form-action action-type="JavaScript" event="Event" annotation-reference="AnnotationId">
...
</xf:form-control>
<xf:form-control name="RadioGroup" type="radiobutton" checked="true | false" value="ValueToSubmitWhenSelected">
<!--One or more actions-->
<xf:form-action action-type="JavaScript" event="Event" annotation-reference="AnnotationId">
...
</xf:form-control>
</xf:form>
For buttons, the caption is specified by the value attribute. For a text edit, the value represents the default text to be displayed; the text edit can be set as multiline (and also scrollable) using the multiline attribute.
Possible values for the event attribute are:
| • | OnMouseUp - triggered after the control was left-clicked and the button is released |
| • | OnMouseDown - triggered when the control is left-clicked and the button is held |
| • | OnMouseEnter - triggered when the mouse cursor enters the form area |
| • | OnMouseExit - triggered when the mouse cursor leaves the form area |
| • | OnFocus - triggered when the control gets focus |
| • | OnBlur - triggered when the control loses focus |
One or more actions can be associated with a control. Each action nested in a form control whose event is triggered is executed. The JavaScript code to execute is nested in the annotation referenced by the annotation-reference attribute of the xf:form-action element.
An annotation with embedded JavaScript code looks like this:
<xf:annotation id="6">
<xf:javascript output-type="pdf">
app.alert("This is a JavaScript alert.");
</xf:javascript>
<xf:javascript output-type="html">
alert("This is a JavaScript alert.");
</xf:javascript>
</xf:annotation>
See the JavaScript Code annotation for more info on including JavaScript into output documents.
Styling controls is supported by using the standard fo:color and fo:background-color attributes. Their effects are as follows: fo:color for the text color and borders, fo:background-color for the button background.