WebSTAR 4 Manual & Technical Reference

Manual Contents | Chapter Contents | Previous Page | Next Page

Creating a Form to Add Records

You can use WebSTAR Lasso Publisher to allow users to add new records to your web-enabled databases. When creating such a form, you must use certain action and command tags. Our example database will be the CDs.fp3 database that can be found in the Tools & Examples folder.

WebSTAR Lasso Publisher allows you to add records to your database, but not edit existing records. For that functionality, you need the Lasso Web Data Engine from BlueWorld.

Add Record Example

Below is an example form with the minimum tags required for adding records. Each line of the form is discussed in detail.

 

<form method="post" action="action.lasso">
 
	<input type="hidden" name="-Database" value="CDs.fp3">
 
	<input type="hidden" name="-Layout" value="Web">
 
	<input type="hidden" name="-Response" value="added.html">
 
		Artist: <input type="text" name="Artist"><br>
 
		Title: <input type="text" name="Title"><br>
 
		Year: <input type="text" name="Year"><br>
 
		Label: <input type="text" name="Label"><br>
 
		Category: <input type="text" name="Category"><br>
 
	<input type="submit" name="-Add" value="Add New Record">
 
</form>

Line 1:

<form method="post" action="action.lasso">
As with any other form, the action attribute tells the web server how to handle the form. The "action.lasso" value ensures that WebSTAR will pass the form off to Lasso.

Line 2:

<input type="hidden" name="-Database" value="CDs.fp3">
This command tag tells Lasso that the information contained in this form is intended for the CDs.fp3 database.

Line 3:

<input type="hidden" name="-Layout" value="Web">
Similar to the above command tag, you must tell Lasso which database layout to access.

Line 4:

<input type="hidden" name="-Response" value="added.html">
This command specifies which page is to be returned after the new record has been added. You may specify a path to the file to be returned, however if the file resides in the same directory as the form page we're working on now, you only need to enter the file name.
Note that the response page does not require any Lasso tags on it. When you create that page, you can simply display a message telling the user their information has been entered into the database.

Lines 5 through 9:

Artist: <input type="text" name="Artist">
Title: <input type="text" name="Title">...
These are standard text input fields where the user enters the information that will comprise the new record. It is important to put the exact name of the field in the name attribute.

Line 10:

<input type="submit" name="-Add" value="Add New Record">
Now that you've told Lasso which database and layout to use, what page to return with the results, and what information is to be included, the -Add action tells Lasso to go ahead and make the new record. The value attribute becomes the button's text.

Line 11:

</form>
Standard HTML, this tag closes the form.

Other Important Tags

While not strictly required, the -AddError and -Required tags are very useful when adding database records.

-AddError

The AddError tag tells Lasso which file to display when there has been an error during an attempt to add a new record.

 

<input type="hidden" name="-AddError" value="adderror.html">

The error page that is returned does not need to have any LDML tags in it. It can simply be a regular HTML document containing a message that an error has occurred.

-Required and -ReqFieldMissingError

The -Required command is used to prevent a field from being submitted empty. To use it, place the command in a hidden field directly before the field you wish to require.

The -ReqFieldMissingError tag tells Lasso which file to display when a required field has been left blank.

Consider this example:

 

<p>
 
<input type="hidden" name="-ReqFieldMissingError" value="reqfielderror.html"> 
 
Artist: <input type="text" name="Artist"><BR>
 
<input type="hidden" name="-Required">
 
Title:<input type="text" name="Title">
 
</p>

A user of the above form may leave the Artist field blank. However, if they leave the Title field blank, Lasso will return the reqfielderror.html page.

The error page that is returned does not need to have any LDML tags in it. It can simply be a regular HTML document containing a message that a required field has been left blank.


Manual Contents | Chapter Contents | Previous Page | Next Page