cs::HTML::Form - support for parsing and generating HTML markup
use cs::HTML;
This module supplies methods constructing HTML forms. It is usually used in CGI scripts via the Form() method from the cs::CGI(3) module.
Create a new cs::HTML::Form object. method is optional and defaults to GET. enctype is optional and defaults to application/x-www-form-urlencoded.
This signifies that you're done with the form. The return value is a single FORM tag containing the entire HTML for the form you've constructed in the same tokenised structure used by the cs::HTML(3) and cs::CGI(3) modules:
[ FORM, { I<attributes...> }, I<tokens...> ]
StackMarkUp()
Save the current markup state and commence a new, empty state. This is mostly for constructing things like TABLEs:
# save state
$F->StackMarkUp();
# build a bunch of rows
for my $n (1..4)
{ $F->MarkUp([TR, [TD, "Label"], [TD, $F->TextFieldMU(...)]]);
}
# pop the rows into a table and add to the old state,
# which is now current again
$F->MarkUp([TABLE, $F->StackedMarkUp()]);
StackedMarkUp()
Return the current markup state in an arrayref, and pop the state stack so the last state pushed is now again the current state.
Defaults()
Return the hashref containing the default field values for the form.
Set the default value for the specified field. If value is omitted, return the current default or undef.
Append the specified HTML tokens to the form's HTML. The tokens are in the usual structured form.
Add a submit button named field with value label to the form.
Return an INPUT token for a submit button named field with value label.
Add a TEXT INPUT token for a text field input (single line) to the form, with initial content value, length size and maximum length maxsize. If value is omitted, the default value for the field is used. If size is omitted, the maximum of 16 and twice the length of the initial value is used. If maxsize is omitted then the field has no maximum length.
Return a TEXT INPUT token for a text field input (single line) with initial content value, length size and maximum length maxsize. If value is omitted, the default value for the field is used. If size is omitted, the maximum of 16 and twice the length of the initial value is used. If maxsize is omitted then the field has no maximum length.
Add a TEXTAREA INPUT token (multiline) to the form with initial content value, rows lines of input and cols columns in width. If value is omitted, the default value for the field is used. If rows is omitted, the maximum of 4 and the number of lines in the initial value is used. If cols is omitted, the maximum of 16 and the widest line in the initial value is used.
Return a TEXTAREA INPUT token (multiline) with initial content value, rows lines of input and cols columns in width. If value is omitted, the default value for the field is used. If rows is omitted, the maximum of 4 and the number of lines in the initial value is used. If cols is omitted, the maximum of 16 and the widest line in the initial value is used.
Add a PASSWORD INPUT token for a text field input (single line, content obscured) to the form with initial content value, length size and maximum length maxsize. If value is omitted, the default value for the field is used. If size is omitted, the maximum of 16 and twice the length of the initial value is used. If maxsize is omitted then the field has no maximum length.
Return a PASSWORD INPUT token for a text field input (single line, content obscured) with initial content value, length size and maximum length maxsize. If value is omitted, the default value for the field is used. If size is omitted, the maximum of 16 and twice the length of the initial value is used. If maxsize is omitted then the field has no maximum length.
Add a hidden field named field with value value to the form.
Return a hidden field token named field with value value.
Add a popup SELECT token for the specified field to the form to choose a single item amongst the specified values (the keys of the hashref map, with descriptive strings being the values of the hashref map). If supplied, the initial value selected is preselected. If supplied, the arrayref keylist specifies a key ordering for the popup; it need not be a complete list of the keys in map.
Return a popup SELECT token for the specified field to choose a single item amongst the specified values (the keys of the hashref map, with descriptive strings being the values of the hashref map). If supplied, the initial value selected is preselected. If supplied, the arrayref keylist specifies a key ordering for the popup; it need not be a complete list of the keys in map.
Add a multiple value SELECT token for the specified field to the form to choose a single item amongst the specified values (the keys of the hashref map, with descriptive strings being the values of the hashref map). If supplied, the initial values in the arrayref selected are preselected. If supplied, the arrayref keylist specifies a key ordering for the popup; it need not be a complete list of the keys in map. If supplied, size specifies the number of options visible in the list at any one time; if omitted it is the minimum of the number of keys and the value 5. If supplied, the multiple parameter specifies whether multiple items may be chosen from the list; it defaults to false.
Return a multiple value SELECT token for the specified field to choose a single item amongst the specified values (the keys of the hashref map, with descriptive strings being the values of the hashref map). If supplied, the initial values in the arrayref selected are preselected. If supplied, the arrayref keylist specifies a key ordering for the popup; it need not be a complete list of the keys in map. If supplied, size specifies the number of options visible in the list at any one time; if omitted it is the minimum of the number of keys and the value 5. If supplied, the multiple parameter specifies whether multiple items may be chosen from the list; it defaults to false.
Add a file upload INPUT token for the specified field.
Return a file upload INPUT token for the specified field.
cs::HTML(3), cs::CGI(3),
Cameron Simpson <cs@zip.com.au>