|MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA|
Forms Extension Framework Documentation03/16/2001
Overview of the Forms Extension Framework
ForX is a set of attributes designed to extend existing form functionality with desirable features such as validation, content types, and groups. ForX is based on two principles:
With ForX, you can specify the elements that must be completed before a form can be submitted. To define these requirements, you use
A "group" makes it easier to handle elements that are not associated by default, such as radio buttons. With a conditional requirement you can have a group that's dependent on another element's value or on a literal value.
A form implementing ForX attributes must have a unique
To make sure a user completed the form correctly, you can use an option to enable a warning after the user tried to send a valid form (which doesn't necessarily mean that the data entered is correct). This element is shown only once (if the form remains valid after reviewing). This behavior is managed by
Required elements and non-valid elements are marked with a special element, which is defined in the same way as the warning element above. You are generally free to fill the template elements with any content you want; you only need to have the correct ID and class.
The template file contains everything you need to get started. (Use right-click to save, or view source -- the unaltered template file will just view as a blank page!) After that, you should examine the example page for some working demos.
ForX uses its own namespace to avoid conflicts with other elements. The prefix for the namespace is defined as
Every element that is referenced by another ForX element needs to have its own unique
To mark any element as being "required" for the form to process, the
You can use a literal value, or the name of another element on the same form, on the right side of the condition. A literal value is indicated by single or double quotation marks.
Checkboxes and radio buttons can use the keyword
An element is required only when the condition evaluates
All required elements need to be specifically marked as defined in the template. A template needs to have class
As long as you meet these requirements, you are free to use whatever you want as your marker. The engine copies this template to all elements and group containers that are required, but not valid.
Elements that allow the user to enter any type of text should be checked to contain a special class of content. For this purpose, ForX defines a set of predefined content types. The content type for an element is defined within the
Predefined content types:
If no content type is specified for a required element, it's assumed to have the
In those cases where a predefined set of content types is not good enough, a regular expression is the only solution. To use a regular expression, it has to be put into the
Groups are probably one of the most desirable features. Just imagine the following situation: You need a form for an online store that allows customers to pay via invoice or credit card. For the latter, you need additional data such as the number and expiration date for the card.
Previously, "in the old days," you'd write a custom function that forked after it detected the customer's selected payment method. With ForX, you can easily group required elements and make them dependent on other elements.
To create such a group you need two things: a container element and a set of member elements.
The container element is needed to place the marker element into, which reminds the user to fill out required fields. If a group is not valid, the marker template is copied and shown in the group container element. The container element is identified by the
The container element also holds the
To highlight all members of a group, you can set the group container's
To define the number of elements that must be valid to make the entire group valid, you use the
To add elements to a group you use the
It's not possible to retrieve the value of a group or to nest groups.
See the example pages for working demos.