Home | Trees | Index | Help |
|
---|
Package aquarium :: Package widget :: Module FormUtil :: Class FormUtil |
|
AquariumClass
--+ |HasFriends
--+ | FormUtil
This is a utility to build consistent HTML forms.
The purpose of this class is not to "abstract" HTML. Its purpose is to provide "macros" so that you can get things done more quickly and consistently. If your needs are very generic, you can use high-level macros like field. In your needs are less generic, you can use middle-level macros like textField and label. At the bottom are very low-level macros like getErrorMsg and getDefault. Naturally, you can subclass this class as needed.
This class also mixes in the HasFriends mixin. That means if you need to add a new method fooField, simply create a new module called aquarium.widget.formutil.fooField containing a function called fooField. The fooField function should accept a FormUtil instance called self as its first argument (i.e. it acts like a method in this class). Then fooField will just work.
The following attributes are used:
The following class attributes are used:
Method Summary | |
---|---|
Accept the arguments. | |
Return a set of HTML tag attributes. | |
Returns a string representing a checkbox. | |
Build a field with a label in a table row. | |
Returns a string representing a file upload field. | |
Output the JavaScript to focus a field. | |
Return the default value for the given field. | |
Return the error message for a field, if present. | |
Return if_ if there was an error, else_ otherwise. | |
Returns a string representing an input field of type type. | |
Return a label and the error message defined by the validator. | |
Return an option for use within a select. | |
Returns a string representing a password field. | |
Returns a string representing a radio button. | |
Returns a string representing a fully fledged select box. | |
Returns a string representing a textarea. | |
Returns a string representing a text field. | |
Inherited from HasFriends | |
Return the desired friend method. |
Class Variable Summary | |
---|---|
str |
errorClass = 'error'
|
str |
labelClass = 'label'
|
Method Details |
---|
__init__(self,
ctx,
defaults=None,
errors=None)
|
attributes(self, attributes)Return a set of HTML tag attributes. |
checkBoxField(self, name, value, **attributes)Returns a string representing a checkbox.
|
field(self, label, name, type, **attributes)Build a field with a label in a table row.
|
fileField(self, name, **attributes)Returns a string representing a file upload field. |
focusField(self, form, field)Output the JavaScript to focus a field. Use this to set the default focus of a form. Call this after you have output the given field.
|
getDefault(self, name)Return the default value for the given field. I will not run htmlent on it. If no default can be found, I'll return "". |
getErrorMsg(self, name, brk=True, **attributes)Return the error message for a field, if present.
I will wrap it with the CSS class self.errorClass. |
ifError(self, name, if_, else_='')Return if_ if there was an error, else_ otherwise. |
inputField(self, name, type, **attributes)Returns a string representing an input field of type type. |
label(self, name=None, label=None, brk=True, **attributes)Return a label and the error message defined by the validator. Wrap it with the CSS class self.labelClass.
|
optionField(self, option, selectedValue)Return an option for use within a select.
|
passwordField(self, name, providePasswordDefault=False, **attributes)Returns a string representing a password field. |
radioField(self, name, value, **attributes)Returns a string representing a radio button.
|
selectField(self, name, options, **attributes)Returns a string representing a fully fledged select box.
|
textAreaField(self, name, **attributes)Returns a string representing a textarea. |
textField(self, name, **attributes)Returns a string representing a text field. |
Class Variable Details |
---|
errorClass
|
labelClass
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon Jan 1 16:34:19 2007 | http://epydoc.sf.net |