>> Table of Contents >> Article

Forms

This section defines the syntax of elements required to declare the structure of forms, which are related to objects in the database. These forms may be used by a client application and refer to database elements, defined within the same document. Forms bind a presentation element (template) to a data source (table or view). The implementation may define the required syntax and interpretation of the templates. These aspects are unspecified in this document.

Element Form

  ELEMENT form (description?, grant*, fieldset*, event*)
  ATTRIBUTE
       name        string
       table       string
       template    string
       title       string
  
Attributes
Attributes Type Mandatory Default Description
name string yes n/a An unique name that identifies this form. It should be lowercased and a valid XML and SQL identifier.
table string - n/a Name einer Quelltabelle oder eines Views. Note that the view should be updatable. Otherwise the form should not be editable
template string - n/a The attribute template may contain any text. The implementation used to generate the forms may provide a list of valid values for this attribute. The template should provide all required information, which the implementation needs, to create the form.
title string - n/a The title is a label text that should be displayed in the UI when viewing this object.
Description

Forms are named objects, that are used as input for a form- or GUI-generator. They must have at least a base table and a template. The base table may of course also be an (updatable) view.

Implementation

Forms are not a database feature. They need to be generated by software for all known DBMS. The contents of the form however are based on the database schema defined in the XDDL file. Based on this information, the implementation should generate select-, update-, insert- or delete-statements automatically.

Presentation

For HTML output, forms should be displayed as HTML form elements. The presentation of the form must be defined in the associated template.

Element Fieldset

  ELEMENT fieldset (description?, grant*, input+)
  ATTRIBUTE
       name     string
       title    string
  
Attributes
Attributes Type Mandatory Default Description
name string - default An unique name that identifies this fieldset. It should be lowercased and a valid XML and SQL identifier.
title string - n/a The title is a label text that should be displayed in the UI when viewing this object.
Description

Fieldsets are meant to group fields. If a fieldset is unnamed, it's name defaults to "default". Thus note, that there must be no more than 1 unnamed fieldset per form. Throughout the form, each fieldset's name must be unique.

Presentation

Fieldset elements should be presented in HTML using "fieldset" tags. The attribute title may be used as "legend" element for the tag.

Element Input

  ELEMENT input (description?, grant*, action*)
  ATTRIBUTE
       name        string
       label       string
       hidden      bool
       readonly    bool
       cssclass    string
       tabindex    integer
  
Attributes
Attributes Type Mandatory Default Description
name string yes n/a An unique name that identifies this input field. It should be lowercased and a valid XML and SQL identifier.
label string - n/a The label is a description field, which provides more information about the content of the input field.
hidden bool - no The input field must not be visible in the UI when the value of this attribute is set to "yes". Otherwise the attribute is to be ignored.
readonly bool - no You may set the input field to be read-only to prevent any changes. An input field that is "read-only" is not updatable.
cssclass string - n/a A HTML-based UI should provide id attributes and CSS classes for fields automatically. Additionally this attribute may be used to add a user-defined CSS class.
tabindex integer - 0 A HTML-based UI should provide the tab-index for fields automatically. Alternatively this attribute may be used to set a user-defined value. The tab-index defines the order in which fields should get the edit focus, when the user hits the tab-key on a keyboard.
Description

The input element is a single field inside a fieldset.

Presentation

A HTML-based UI should display this as an "input" element, or something familiar, depending on the type of the underlying column. If the attribute "readonly" is set to "yes", the element should not be editable. The implementation should create CSS class- and/or id-attributes for each input field. Additionally if the attribute "cssclass" is set, this value has to be added to the class attribute of the tag. If the attribute "tabindex" is provided, it is to be copied to the attribute list of the control element. If the "input" element is represented by more then one HTML field, the tabindex should be set to the first editable field.

Element action

  ELEMENT action (#PCDATA)
  ATTRIBUTE
       name     string
       language string
       title    string
       label    string
       icon     image
  
Attributes
Attributes Type Mandatory Default Description
name string yes n/a An unique name that identifies this action. It should be lowercased and a valid function name.
language string - n/a The programming language of the action implementation. May be any string. If the option is not set, the implementation may decide itself how to handle the action. The Yana Framework will interpret the action as the name of a defined plug-in action.
title string - n/a Title-attribute for clickable links.
label string - n/a Text label used for clickable links.
icon image - n/a Image file used as icon for clickable links.
Description

The action element is meant to be triggered when the user clicks the form field.

Presentation

The presentation of the element depends on the attributes language and name.

If the language is set to PHP, or if the attribute language is empty, it is recommended to be displayed as an A-tag next to the form field. The content of the tag is the attribute "label" and/or an img-tag, where the src-attribute is taken from the "icon" attribute of the element. The href-attribute of the tag should be a reference to PHP_SELF plus the name of the action as parameter, provided as "action={name}". The value of the field should be provided as a second parameter "target[{primary_key}]={value}"

Example:

  <action name="foo" label="click me"
      icon="common_files/icon.png"/>

  <a href="?action=foo&target[12]=bar">
    click me
    <img src="common_files/icon.png"/>
  </a>

If the language is set to JavaScript, the name must be a valid JavaScript event and the pcdata section must be valid JavaScript code.

Example:

  <action name="onchange" language="javascript">validate(this)</action>

  <input ... onchange="validate(this)"/>

If a label or icon is provided, the action should also be triggered when clicking the label and/or icon.

Example:

  <action name="onchange" label="validate"
      icon="common_files/validate.png"
      language="javascript">validate('foo')</action>

  <input ... onchange="validate('foo')" />
  <a onclick="validate('foo')">
      validate
      <img src="common_files/validate.png"/>
  </a>

Element Event

  ELEMENT event (#PCDATA)
  ATTRIBUTE
       name     string
  
Attributes
Attributes Type Mandatory Default Description
name string yes n/a Name of event to be triggered (as defined by the chosen template)
Description

The event is triggered when the user performs a certain action in the form, like submitting the form, clicking a download or something similar. The available types of events must be defined by the chosen template. The implementation may define how to execute the event. The attribute "name" defines the name of the event and the PCDATA section provides the name of the function to be called.

Example: event "submit" with pcdata "foo" will send the form data (using the POST method) to the server application at the URL "?action=foo", when the user submits the form. The implementation must define, what "submit" actually means for the given form template.

Author: Thomas Meyer, www.yanaframework.net