gs.content.form.base
API Reference¶
The package exports the following API symbols.
Site form¶
The abstract base-class gs.content.form.SiteForm
is a Zope
PageForm
provides the siteInfo
and loggedInUser
properties.
Example¶
from gs.content.form.form import SiteForm
class Change(SiteForm):
def __init__(self, context, request):
super(Change, self).__init__(context, request)
Widgets¶
Four custom widgets are provided: radio buttons, check boxes, a select, and a disabled text entry.
Radio buttons¶
The widget gs.content.form.base.radio_widget()
is a variant
of the standard zope.formlib
raido button, but it has the
correct association between the label and the button.
-
gs.content.form.base.
radio_widget
(field, request)[source]¶ Create a radio-widget with a clickable label.
Parameters: - field – The field that the radio-widget is created for.
- request – The current HTTP request.
Returns: A radio widget.
Example¶
@Lazy
def form_fields(self):
retval = form.Fields(IChange, render_context=False)
retval['field'].custom_widget = radio_widget
Check Boxes¶
Rather than a select, it is often nicer to present a list of
checkboxes. This is especially true if the user is supposed to
select multiple items (which is normally done using the
Control key in a select-box, but few people know this). The
gs.content.form.base.multi_check_box_widget()
widget
displays a list of checkboxes based on a vocabulary
-
gs.content.form.base.
multi_check_box_widget
(field, request)[source]¶ Create a widget with multiple check-boxes.
Parameters: - field – The field that the checkbox-widget is created for.
- request – The current HTTP request.
Returns: A multi-checkbox widget.
Example¶
@Lazy
def form_fields(self):
retval = form.Fields(IChange, render_context=False)
retval['field'].custom_widget = multi_check_box_widget
Select¶
The standard Zope select widget annoying sets the size too
small. The gs.content.form.base.select_widget()
creates a
select box that shows 15 items. If fewer items are desired then
radio buttons or check boxes should be used:
-
gs.content.form.base.
select_widget
(field, request)[source]¶ Create a select-widget that is larget than normal
Parameters: - field – The field that the radio-widget is created for.
- request – The current HTTP request.
Returns: A select widget.
Return type: zope.app.form.brower.SelectWidget
Example¶
@Lazy
def form_fields(self):
retval = form.Fields(IChange, render_context=False)
retval['field'].custom_widget = select_widget
Disabled Text¶
The gs.content.form.base.disabled_text_widget
factory creates
a text widget that has the CSS class set to disabled
.