NAME

AppLib HTML Form Element Generator

DESCRIPTION

The AppLib::HTML::Form package is a class containing a series of static methods used to generate HTML form elements in a more logical way than the pure CGI.pm module approach.

AppLib::HTML::Form does not use CGI.pm to generate any of it's html, it prefers to use it's own internal tag generators in AppLib::HTML.

METHODS

textbox( $name, $value, \%options )

The textbox method generates a regular textbox.

The $name argument defines the name property for the text box.

The $value argument defines a default value for the text box. By default, this value will be automatically escaped for use as a html property, so that any value can be used, and it will become safe HTML. This primarily affect things like quotes and angle brackets in the value.

An optional hashref containing options can be provided. Some of these are recognised internally, and the some are passed on as additional properties to be added to the <input> tag. The remainder are ignored.

dontescape

The dontescape options, if provided, will cause the generator to assume that $value is already escaped, and to not escape it again.

class

Any class option is passed through to define a stylesheet class for the textbox.

size

Any size option is passed through to the textbox.

maxlength

Any maxlength option is passed through to the textbox.

The textbox method returns a HTML string on success, or undef on error.

textarea( $name, $content, \%options )

The textarea method generates a regular textarea input.

The $name argument defines the name property of the textarea.

The $content argument defines the initial contents of the textarea. This contents is automatically escaped by default for use as the textarea content.

An optional hashref containing options can be provided. Some of these are recognised internally, some are passed on as additional properties to add to the <input> tag, and the remainder are ignored.

dontescape

The dontescape options, if provided, will cause the generator to assume that $contents is already escaped, and to not escape it again.

cols

The cols option will be passed through as a textarea property.

rows

The rows option will be passed through as a textarea property.

class

The class option will be passed through as a textarea property, to define the style used for the textarea.

wrap

The wrap options option, if provided, will be passed through as a textarea property, to define the wrapping form to use.

dropbox( $name, \@data, $value, \%options )

The dropbox method generates a dropbox based on a select tag.

The $name argument defines the name property of the textarea.

The \@data argument is a reference to an array that contains a series of 'options'. The single option consist of a reference an a 2 element array, where the first element is the 'value' of the options, and the second element is the 'label' displayed to the user.

An simple example argument would be

# Example data set
my $data = [
  [ 1, 'One' ],
  [ 2, 'Two' ],
  [ 3, 'Three' ],
  ];

In many dropboxs, text is provided for the null case, for when nothing is selected. In out case, this is the label provided for the value '', as seen above.

The $value argument is the initial value to set the dropbox to, null by default. If should be passed as undef is no value is to be selected by default.

An optional hashref containing options can be provided. Some of these are recognised internally, some are passed on as additional properties to add to the <select> or <option> tags, and the remainder are ignored.

dontescape

The dontescape option, if provided, will cause the generator to assume that the labels are already escaped, and to not escape it again. The values are never escaped.

class

The class option, if provided, will set a class value for the select tag.

onChange

The onChange option, if provided, will be passed through to the select tag to specify a javascript action to take when the dropbox is changed.

notnull

The notnull option, if set to true, causes the generator to not show the null option.

nullstring

The nullstring option, if provided, specifies a string to display for the null option, unless it has been provided in the options, as the [ '', 'nullstring' ] option.

radio( $name, \@data, $value, $layout, \%options )

TO BE COMPLETED

checkbox( $name, $value, \%options )

TO BE COMPLETED

hidden( $name, $value )

TODO

This module is not as complete as I would like, but nothing immediately springs to mind to do to it.

COPYRIGHT

Copyright (C) 2000-2002 Adam Kennedy

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Should you wish to utilise this software under a different licence, please contact the author.