Component index
Section index

Component form


Search

Type

Function

Summary

Control the an HTML form

Description

This controls all the steps needed to handle a form, including the initial layout, validation and processing.

void bottom ()
void load ()
void process ()
void setup (bool first, bool drawing)
void top ()
bool validate ()

Prototypes

void form ()

Functags

void bottom () Optional

Draw some HTML code after the form

Useful to add extra information outside of the form.

void load () Optional

Used to load various information prior to validation and setup

If you need to load information from a database, prior to do the setup of the form, you place your code here.

void process () Mandatory

Called when the user input has been validated and accepted

The functag must now perform the action associated to this form.

void setup (bool first, bool drawing) Mandatory

Perform the layout of the from

You use HTML code but also the field_xxx() helpers to layout the form.

void top () Optional

Draw some HTML code at the top of the form

Useful if you need some introduction text before the form is created.

bool validate () Mandatory

Return true if the input is valid

The function returns true or false if the user input is valid or not. It also issues error message using tlmpweb_error().

Fhelpers

void button_submit ()

Position the submit button in the form layout

By default, the submit button is just drawn at the end of the form. Using this function, you can position it as needed.

void button_submit (const char *title)

Position the submit button and set the label

Like the other button_submit, except you can specify the button label.

void field_checkbox (const char *name, bool selected, cnnst char *opt)

Setup a check-box field in the form

void field_file (const char *name)

Setup a file upload field

void field_file (W_VAR &var)

Setup a file upload field using a WEB variable

void field_hidden (const char *name, const char *value)

Setup a hidden field with a value

This is useful to store information in the form, transmitted back to the application by the browser when the user "accept" the form.

void field_list (const char *name, const char *value, const char *opt)

Setup a list

You use field_list, then field_list_item() to define the items and then field_list_end() to end the list

void field_list_end ()

Ends the list definition

void field_list_item (const char *value)

Define one entry in the list

void field_list_item (const char *value, const char *description)

Define one entry in the list

Entries are presented with some text, but the value is another This one associate a description to the item value. Only the description is presented.

void field_password (W_VAR &var, const char *opt)

Define a field without user input echoing

void field_password (const char *name, const char *opt)

Define a password field

void field_radio (const char *name, const char *value, bool selected, const char *opt)

Define a radio button

A radio button is a exclusive selector. When one button is selected all the other are deselected

void field_string (W_VAR &var, const char *opt)

One line text field

void field_string (const char *name, const char *value, const char *opt)

One line text field

void field_testarea (const char *name, int rows, int cols, const char *opt)

Define a multi-line text field

You must call this function, then field_textarea_body() several time to set the initial content and then field_textarea_end() to end the definition.

void field_testarea_end ()

Ends the textarea definition

void field_textarea (W_VAR &var, int rows, int cols, const char *opt)

Define a multi-line text field

You must call this function, then field_textarea_body() several time to set the initial content and then field_textarea_end() to end the definition.

void field_textarea_body (const char *ctl, ...)

Define one line of the textarea

This function is generally called several time to define the content of the multi-line textarea. This function works like printf.

void fputs (const char *s, FILE *f)

Send some strings to the HTML stream

This function works as well for other FILE handle

void no_submit ()

Tells we do not want any submit button in this form

This is usually needed for form using either custom buttons or images.

void printf (const char *ctl, ...)

Send some formatted strings to the HTML stream

Works like a normal printf, except everything is sent to the form. This is usually used in the top,bottom and setup functag.

void setfield (const char *name, const char *type, const char *value, const char *opt)

Define an arbitrary HTML field

You normally use the various field_xxx() helper to define field. You use setfield for other field type (since not all HTML input type have their field_xxxx() helper).