Form Definition File Syntax

TOC:

General file format

Form definition files (.fdf's) are basically just a set of attribute definitions. First a set of attributes for the form as a whole are defined, then a set of attributes for each field in the form. All attribute definitions are of the form :

Attribute = value

Blank lines are ignored. In the original WDBI all characters after a '#' were ignored as well. That royally screwed up URLs that had '#' symbols in them, so I took that out. It is important that there is no whitespace before the attribute name. Lines beginning with white-space are considered continuation lines of the previous attribute definition. Leading and trailing whitespace are removed from the attribute values.

INCLUDE field type
If you find yourself adding the same FDF form and field attributes over and over in several FDFs, now you can put them all in a single file and just include them in your other FDFs. Just specify a line of the form:

    INCLUDE = /filesystem/path/to/your/include/file
and anything you put in the included file will show up in WDBI as if they were explicitly written in the FDF.

Form Attributes

All form attributes are always before any field definitions in the file, and always in CAPITAL letters.

In the following an (R) means that the attribute is required, and an (E) means that the attribute values is evaluated by a perl eval command. Remember to quote strings in attribute values that are evaluated!

Because so many new attributes have been added, they have been divided into categories to organize them better so you can find what you are looking for more easily.

Required FDF Attributes

Query Constraint FDF Attributes

Query Results Formatting FDF Attributes

General FDF Attributes

Counter FDF Attributes

Normal Query And Result Headers

Delete Attributes

Insert Attributes

Update Attributes

Field Attributes

Field attributes always appears after all form attributes in the file. The 'FIELD' attribute should always be the first attribute for a field. All attributes defined after this will belong to that field, until the next 'FIELD' attribute is met.

In the following an (R) means that the attribute is required, and an (E) means that the attribute value is evaluated by a perl eval command. Remember to quote strings in attribute values that are evaluated !

Because so many new attributes have been added, they have been divided into categories to organize them better so you can find what you are looking for more easily.

Required Field Attributes

Key Field Attributes

Query (Select, Insert, Update, or Delete) Form Field Attributes

Tabular Output Field Attributes

Full-Screen Output Field Attributes

Output Field Attributes Used in Both Tabular and Full-Screen Output

Item Selection Field Attributes

Special Field Attributes

Internal Variables

There are some internal Perl variables that can be referenced in the attribute definitions above. Most of them have already been mentioned, but to summarize they are all listed here :

$val{'fieldname'}
Value returned from the database after the query has been performed. This is typically used in from_db and url.

$val
Value of the users input in the current field after special characters ( <, >, =) has been removed. This is typically used in to_db.

$form{'form-attribute'}
The value of a form attribute. This is not really needed, unless in order to avoid duplicating things. For example $form{'NAME'} could be used in the url attribute, so if the name of the form is changed only the NAME attribute needs to be changed.

$field{'field-name','attribute-name'}
The value of a field attribute. Not really needed by the form writer.

$WDBI
The name of the script used to access this form. This is set by wdbi on each invocation. If used in url references it is a lot easier to test different versions of wdbi on the same FDF files. This variable should not be changed !

$MAIN_MENU
A URL to the main menu of forms, or the homepage. This URL is used for the 'Home' button.

$QUERY_HELP
A URL to the query help. This URL is used for the 'Help' button.

$NULL_VALUE
The value to display as the NULL value. (default is an empty string "").

$MAXROWCOUNT
The Maximum allowed value for the 'Return max .... rows' field.

Note: May be overridden in the FDF with the MAXROWCOUNT attribute.

$ROWCOUNT
The default value for the above field. This controls the maximum number of rows that can be returned from a query.

Note: May be overridden in the FDF with the ROWCOUNT attribute.

Functions

These are functions build into WDBI - However you can always add your own functions as well and include them either directly in the FDF file (under the PERL form attribute) or include them in your own Perl package and install it in your Perl library directory - then include them with the Perl 'require' statement in the PERL attribute or in the wdbi.conf file to make them available in all your FDF files.

&add_menu( $text, $href, $img )
This function can be used in the PERL form attribute to add extra menu options next to the Submit, Reset, Help, etc. buttons. Either a text or a GIF button can be used. ( See appendix on how to create GIF buttons. )

$text
- is the text label to use, either directly or as the ALT attribute if a GIF button is supplied.

$href
- is the URL to execute when the button is pressed.

$img
- is the URL to the GIF file to use as button. If this argument is left out a normal text link is created instead.

&cgi_encode( $str )
Encodes a string so it doesn't cause problems in a URL. If you have a keyvalue that could contain special characters like spaces, % signs etc. you can't just included it in a normal url like :

    url = "$WDBI/$form{'DATABASE'}/$form{'NAME'}/query/$val{'keyfield'}"

In this case you would have to encode the key value using cgi_encode like this :

    url = "$WDBI/$form{'DATABASE'}/$form{'NAME'}/query/" . &cgi_encode($val{'keyfield'})

Copyright © 1996-98 Bo Frese Rasmussen and Jeff Rowe