1.8.4.1 web.form.field.basic -- Various fields for use with web.form

class Field( name,[default=''],[description=''][,error=''][,required=False][,requiredError='Please enter a value'])
basic.Field is an abstract class from which other classes are derived.
name
The name of the field.
default
The default value of the field
description
A description of the field for use as part of a form
error
The error message to initialise the field with
required
If True a value must be entered. A string '' is not a valid value. If required=True default cannot be ''.
requiredError
A string containing the error to display if no value is entered.
populate( values)
Populates the field from a web.cgi object.
values
The web.cgi object to use.
valid( [value=None])
Populates the field from a web.cgi object.
value
The value to validate. If value=None then the current value of the field if validated instead. Returns True or False.
html( )
Returns the object as an HTML string
frozen( )
Returns a string representation of the field
hidden( )
Returns the field as a hidden field
error( )
Returns the contents of the error string
setError( error)
Set the error of the field to error
description( )
Returns the contents of the description string
name( )
Returns the name of the field
value
The value of the field

class Input( name[,default=''][,description=''][,error=''][,required=False][,requiredError='Please enter a value'],[,size=40][,maxlength=None])
size
Size of the filed. The number of characters that are displayed
maxlength
The maximum number of characters which can be entered into the field. None means there is no limit.

class Password( name[,default=''][,description=''][,error=''][,required=False][,requiredError='Please enter a value'],[,size=40][,maxlength=None])
size
Size of the filed. The number of characters that are displayed
maxlength
The maximum number of characters which can be entered into the field. None means there is no limit.

class Hidden( name,[default=''],[description=''][,error=''][,required=False][,requiredError='Please enter a value'])
Note: Although you can, it makes little sense to set or read an error on a hidden field.

class Checkbox( name[,default=''][,description=''][,error=''][,required=False][,requiredError='Please enter a value'])
default
The default can only be 'on' or ''

class Submit( name[,default=''][,description=''][,error=''][,required=False][,requiredError='Please enter a value'])
Creates a submit button. Same methods and attributes as basic.Field

class Reset( name[,default=''][,description=''][,error=''][,required=False][,requiredError='Please enter a value'])
Creates a reset button. Same methods and attributes as basic.Field

class TextArea( name[,default=''][,description=''][,error=''][,required=False][,requiredError='Please enter a value'][,cols=None][,rows=None])
cols
The number of columns in the field. (The number of characters that are displayed in each row). None means not set.
rows
The number of rows of text on display before the box has to scroll. None means not set.

class File( name[,default=''],[description=''][,error=''][,required=False][,requiredError='Please enter a value'])
For file uploads.

Note: If a web.form.Form object has a web.form.field.basic.File field, the method parameter should be set to 'POST' and the enctype should be set to 'multipart/form-data' for file uploads to work.

class Select( name,options[,default=''][,description=''][,error=''][,required=False][,requiredError='Please choose an option'])
options
Should be a list or tuple of [value, label] pairs. Each value or label should be a string. Each value should be unique.
default
A string equal to the value of the default option.

class RadioGroup( name,options[,default=''][,description=''][,error=''][,required=False][,requiredError='Please choose an option'][,align='horiz'][,cols=4])
options
Should be a list or tuple of [value, label] pairs. Each value or label should be a string. Each value should be unique.
default
A string equal to the value of the default option.
align
Can be 'horiz', 'vert' or 'table'

class Menu( name,options[,default=[]][,description=''][,error=''][,required=False][,requiredError='Please choose at least one option'])
options
Should be a list or tuple of [value, label] pairs. Each value or label should be a string. Each value should be unique.
default
A list or tuple of strings for all the default values to be selected.
value
The value of the field returned as a List.

class CheckBoxGroup( name,options[,default=[]][,description=''][,error=''][,required=False][,requiredError='Please choose at least one option'][,align='vert'][,cols=4])
options
Should be a list or tuple of [value, label] pairs. Each value or label should be a string. Each value should be unique.
default
A list or tuple of strings for all the default values to be selected.
align
Can be 'horiz', 'vert' or 'table'
cols
If align='table', cols should be an integer specifying the number of columns in the table.
value
The value of the field returned as a List.