PHP. html_form

Contains various methods for creating HTML FORM widgets and processing them.

Summary
Contains various methods for creating HTML FORM widgets and processing them.
Color selection widget.
Creates the HTML form equivalent of a combination widget (selection and manual entry).
Derives the value passed by a combination widget generated by html_form::combo_widget.
Creates a link which requires a confirmation before proceeding to its destination.
Creates a submit button
Create a picklist of countries
Adds leading zeros to a number
Creates a number picklist.
Create code for single option as part of an XHTML SELECT widget
Creates a picklist widget
Creates a checkbox widget
Creates a pre-formatted simple table for displaying HTML forms
Creates a password (hidden text) widget
Creates a radio box widget
Creates a picklist of United States states
Creates a text area widget
Creates a text widget

Functions

html_form:: color_widget

Color selection widget.

WARNINGThis is just awful, and needs to be replaced with something that makes more sense.

Parameters

$varnameVariable name

Returns

XHTML widget

html_form:: combo_widget

Creates the HTML form equivalent of a combination widget (selection and manual entry).

Parameters

$varnameName of the global variable to store and retrieve the current value from.
$valuesArray of values for the selection portion of the widget.

Returns

XHTML-compliant combination widget code

See Also

html_form::combo_assemble

html_form:: combo_assemble

Derives the value passed by a combination widget generated by html_form::combo_widget.

Parameters

$varnameName of the variable containing the widget form data.

Returns

Scalar value.

See Also

html_form::combo_widget

html_form:: confirm_link_widget

Creates a link which requires a confirmation before proceeding to its destination.

Parameters

$linkURL location for the link to go to
$link_textText that is shown in the A tag
$_options(optional) Associative array containing optional parameters.  Possible values are:
  • confirm_text - Text of the actual confirmation message.
  • class - Class of the A tag

Returns

XHTML-compliant confirmation widget code.

html_form:: submit

Creates a submit button

Parameters

$textText on the submit button
$_options(optional) Associative array of options
  • class - CLASS property of submit button
  • name - NAME property of submit button
  • style - STYLE property of submit button

Returns

XHTML-compliant INPUT TYPE=submit button code

html_form:: country_pulldown

Create a picklist of countries

Parameters

$varnameName of the variable containing the data for this widget

Returns

XHTML-compliant country picklist widget code

html_form:: _addzero

Adds leading zeros to a number

Paramters

$numberInitial number to process
$maxMaximum number to even length to.  (A max value of 10000 would make a number of 10 become “00010”)

Returns

Processed number.

html_form:: number_pulldown

Creates a number picklist.

Parameters

$varnameName of the variable encapsulating the data for this widget.
$startBeginning number
$endEnding number
$step(optional) Incremental value between numbers.  Default is 1.
$addzero(optional) Boolean, make all numbers flush with longest number.  Defaults to true.

Returns

XHTML-compliant number picklist widget code.

See Also

html_form::_addzero

html_form:: select_option

Create code for single option as part of an XHTML SELECT widget

Parameters

$varnameName of variable that encapsulates the data for this widget
$valueValue of this select item
$text(optional) Text that is displayed for this select value.  If this is not given, it defaults to $value.

Returns

XHTML OPTION sub-widget code

See Also

html_form::select_widget

html_form:: select_widget

Creates a picklist widget

Parameters

$varnameName of the variable that encapsulates the data for this widget
$valuesAn associative array of values defining the possible options for this array.  Keys are the displayed text, and values are the values passed back to the program.
$_options(optional) Associative array of optional parameters.
  • array_index - Index of $varname, if $varname is an array
  • class - Defines the CLASS parameter
  • form_name - Name of the HTML form that this widget is placed in.  Required for refresh to work most of the time.
  • on_change - Defines the onChange Javascript parameter
  • refresh - Defines whether the widget will submit the entire form when the value changes
  • style - Defines the STYLE parameter

html_form:: checkbox_widget

Creates a checkbox widget

Parameters

$varnameName of the variable containing the data for the widget
$valueValue that checking off this box will return.
$text(optional) Text that will be displayed next to the checkbox.  If this is not given, it will default to $value.
$helptext(optional) Text that will be displayed in a mouseover of the text next to the checkbox.  Defaults to none.

Returns

XHTML-compliant checkbox widget code

html_form:: form_table

Creates a pre-formatted simple table for displaying HTML forms

Parameters

$cellsAssociative array, with the keys being labels for cells and their values being the code put in corresponding cells.  Be careful not to duplicate keys, as those entries will be lost (append spaces to duplicate labels to avoid this).
$error_bg(optional) Background color of items containing errors, in #RRGGBB format.  Defaults to #ff8888.
$error_fg(optional) Foreground color of items containing errors, in #RRGGBB format.  Defaults to #ffffff.
$seperator(optional) Characters used to seperate the labels from their items.  Defaults to ‘ : ‘.

Returns

XHTML-compliant form table code.

Example

print html_form::form_table(array(
"Item 1" => html_form::text_widget('item1'),
"Item 2" => html_form::text_widget('item2')
));

html_form:: password_widget

Creates a password (hidden text) widget

Parameters

$varnameName of the variable that encapsulates the data of the widget.
$length(optional) Size of the password widget box, in characters.  Defaults to 20.
$maxlength(optional) Maximum allowable text length.  Defaults to $length.
$array_index(optional) Index of the $varname array that this widget is acting on.  Defaults to no array present.

Returns

XHTML-compliant password widget code.

See Also

html_form::text_widget

html_form:: radio_widget

Creates a radio box widget

Parameters

$varnameName of the variable which encapsulates the data for the widget
$valueValue that this radio widget produces, if selected.
$text(optional) Text which is shown to the side of the widget.  Defaults to $value.

Returns

XHTML-compliant INPUT TYPE=RADIO widget code

html_form:: state_pulldown

Creates a picklist of United States states

Parameters

$varnameName of the variable that contains the data for the widget
$is_full(optional) Boolean, whether the full state names will be displayed.  Defaults to false.

Returns

XHTML-compliant state picklist

html_form:: text_area

Creates a text area widget

Parameters

$varnameName of the variable the contains the data for the widget
$wrap(optional) Type of wrapping, as is passed to the HTML TEXTAREA tag.  Defaults to “ON”.
$rows(optional) Number of rows in the text box.  Defaults to 4.
$cols(optional) Number of columns in the text box.  Defaults to 40.

Returns

XHTML-compliant TEXTAREA widget code

html_form:: text_widget

Creates a text widget

Parameters

$varnameName of the variable that contains the data used by the widget
$_options(optional) Associative array of optional parameters.
  • id - HTML ID parameters
  • length - Size of this widget, in characters
  • refresh - Boolean, whether the page is refreshed when focus on this widget is lost.  Defaults to false.

Returns

XHTML-compliant INPUT TYPE=TEXT widget code

Creates the HTML form equivalent of a combination widget (selection and manual entry).
Derives the value passed by a combination widget generated by html_form::combo_widget.
Adds leading zeros to a number
Creates a picklist widget
Creates a text widget