webformmerge
FOLDER
,
TEMPLATE
,
RESULT
,
BLANK
,
VARIABLES

The webformmerge statement fills in an HTML form with database values (fields and variables).


Parameters

This statement has five parameters:

folder – folder containing the template (or “” if template is in the same folder as the database, or if template name contains full path). When using Panorama X, this parameter is usually left blank and the path is placed in the second parameter.

template – HTML template for form. This can either be the name (or path+name) of a file containing the template, or the template itself. If the latter, the HTML code must include the </form> tag.

result – field or variable where the final result will be placed. If empty or missing, the final result will be placed in the cgiHTML global variable.

blank – specifies whether a blank form should be generated (no data). If this parameter is false then both variables and fields will be merged into the HTML. If this parameter is true then only variables will be merged, not fields.

variables – dictionary of variable names and values to be merged into text editor cells, radio buttons, pop-up menus, etc. Note that this is a dictionary, not a carriage return delimited list like it was in Panorama 6 and earlier. Use the dictionaryfromvariables( function to assemble this dictionary.


Description

This statement fills in an HTML form with database values (fields and variables). The data items on the form must be in an exact special format as described below in the section Special Format for Data Items.

Important Note: The webformmerge statement is not normally used directly. Instead, normal practice is to use the renderwebform statement or renderwebform( function. These operations automatically invoke the webformmerge statement for you. The webformmerge statement is included for compatibility with legacy applications, but we recommend using renderwebform for new applications.

Here is the most basic way to use this statement. This example takes the Invoice web form, and merges the fields from the current database record into the web form items. The result is placed into the cgiHTML global variable, ready for passing back to the browser.

webformmerge "", getwebtemplatetext("Invoice")

If you want to put the result in a different variable, you can specify that.

local tempHTML
webformerge "", getwebtemplatetext("Invoice"),tempHTML

If you want to render a form with blank data items, make the fourth parameter true. Instead of filling in the data items with data from the current database record, the items will be made blank.

webformmerge "", getwebtemplatetext("Invoice"),"",true()

If your web form was created with Panorama (see Converting a Panorama Form into a Web Form), it can also include data items linked to variables, and that will be handled automatically. If you hand coded your web form, you must explicitly specify the variables used (if any) with the 5th parameter. You must specify the variables using the dictionaryfromvariables( function (note that this is different from Panorama 6).

webformmerge "", getwebtemplatetext("Invoice"),"",false(),
    dictionaryfromvariables("Discount"+cr()+"Flyer")

Embedding Formulas into the HTML Template

You can embed Panorama formulas into the web form template by enclosing them with ~{ and }~. These formulas can include fields and/or variables, including local variables. This example will display an address label based on data in the current record of the database. There are three formulas embedded into this template.

let labelTemplate = |||<body>
~{First+" "+Last}~<br>
~{Address}~<br>
~{upperword(City)+", "+upper(State)+" "+Zip}~
</body>|||
webformmerge "",labelTemplate,cgiHTML

If any of the formulas contain an error (for example a field or variable that does not exist), the webformmerge statement will return an error. You can trap the error with if error (see Error Handling), but it’s a good idea to eliminate all possible formula errors in your template before putting your server application into production.

Special Format for Input Data Items

Any <input>, <hidden>, <textarea> or <select> tags in the web form template must be arranged exactly in the format described below, or the data won’t be merged properly. If the web form is generated by Panorama (see Converting a Panorama Form into a Web Form), this is taken care of for you, but if you hand code your web form, it must exactly follow the rules described below.

Text input fields must be set up like this:

<input type="text" name="Field" value="" size=20>

The name= parameter must appear just before the value= parameter, with one space in between. Both name= and value= must be in all lower case. You cannot omit the value="" parameter. There must be quotes around the field name, and the value must be "". The arrangement of the other options doesn’t matter.

Checkboxes and radio buttons must be set up like this:

<input type="checkbox/radio" name="Field" value="value"> value

The name= parameter must appear just before the value= parameter, with one space in between. Both name= and value= must be in all lower case. There must be quotes around the field name and the value. Do not include a checked option in the tag - the webformmerge statement will do that for you. The arrangement of the other options doesn’t matter.

Multiline input fields must be set up like this:

<textarea cols=40 rows=6 name="Field"></textarea>

The name= parameter must appear at the end of the tag, right before the >, and it must be quoted, and name= must be in lower case. There must be no blanks between the > and </textarea>. The arrangement of the other options doesn’t matter.

Pop-up menus and scrolling lists require a slightly non-standard format. The <select> tag is the same as normal, but the <option> tags must be formatted like this:

<name="Field" option>value

The name= must appear just before option, with one space in between. Both name= and option must be in all lower case. There must be quotes around the field name. There must be a carriage return after the value. Here is an example of a pop-up menu that will work with the webformmerge statement.

<select size=1 name="Color">
    <name="Color" option>Red
    <name="Color" option>Blue
    <name="Color" option>Green
    <name="Color" option>Orange
    <name="Color" option>Purple
    <name="Color" option>Yellow
    <name="Color" option>Gold
    <name="Color" option>Silver
</select>

See Also


History

VersionStatusNotes
10.2UpdatedCarried over from Panorama 6.0, with updates in the way variables are handled.