wuttaweb.forms.widgets¶
Form widgets
This module defines some custom widgets for use with WuttaWeb.
However for convenience it also makes other Deform widgets available in the namespace:
deform.widget.Widget(base class)
- class wuttaweb.forms.widgets.BatchIdWidget(**kw)[source]¶
Widget for use with the
idfield of a batch model.This widget is “always” read-only and renders the Batch ID as zero-padded 8-char string
- class wuttaweb.forms.widgets.EmailRecipientsWidget(**kw)[source]¶
Widget for email setting recipient fields (
To,Cc,Bcc).This is a subclass of
deform.widget.TextAreaWidget. It uses these Deform templates:textareareadonly/email_recips
See also the
EmailRecipientsschema type, which uses this widget.
- class wuttaweb.forms.widgets.FileDownloadWidget(request, *args, **kwargs)[source]¶
Widget for use with
FileDownloadfields.This only supports readonly, and shows a hyperlink to download the file. Link text is the filename plus file size.
This is a subclass of
deform.widget.Widgetand uses these Deform templates:readonly/filedownload
- Parameters:
request – Current request object.
url – Optional URL for hyperlink. If not specified, file name/size is shown with no hyperlink.
- class wuttaweb.forms.widgets.GridWidget(request, grid, *args, **kwargs)[source]¶
Widget for fields whose data is represented by a grid.
This is a subclass of
deform.widget.Widgetbut does not use any Deform templates.This widget only supports “readonly” mode, is not editable. It is merely a convenience around the grid itself, which does the heavy lifting.
Instead of creating this widget directly you probably should call
set_grid()on your form.- serialize(field, cstruct, **kw)[source]¶
This widget simply calls
render_table_element()on thegridto serialize.
- class wuttaweb.forms.widgets.NotesWidget(**kw)[source]¶
Widget for use with “notes” fields.
In readonly mode, this shows the notes with a background to make them stand out a bit more.
Otherwise it effectively shows a
<textarea>input element.This is a subclass of
deform.widget.TextAreaWidgetand uses these Deform templates:textareareadonly/notes
- class wuttaweb.forms.widgets.ObjectRefWidget(request, *args, **kwargs)[source]¶
Widget for use with model “object reference” fields, e.g. foreign key UUID => TargetModel instance.
While you may create instances of this widget directly, it normally happens automatically when schema nodes of the
ObjectRef(sub)type are part of the form schema; viawidget_maker().In readonly mode, this renders a
<span>tag around themodel_instance(converted to string).Otherwise it renders a select (dropdown) element allowing user to choose from available records.
This is a subclass of
deform.widget.SelectWidgetand uses these Deform templates:selectreadonly/objectref
- class wuttaweb.forms.widgets.PermissionsWidget(request, *args, **kwargs)[source]¶
Widget for use with Role
permissionsfield.This is a subclass of
WuttaCheckboxChoiceWidget. It uses these Deform templates:permissionsreadonly/permissions
- class wuttaweb.forms.widgets.RoleRefsWidget(request, *args, **kwargs)[source]¶
Widget for use with User
rolesfield. This is the default widget for theRoleRefstype.This is a subclass of
WuttaCheckboxChoiceWidget.
- class wuttaweb.forms.widgets.WuttaCheckboxChoiceWidget(request, *args, **kwargs)[source]¶
Custom widget for
setfields.This is a subclass of
deform.widget.CheckboxChoiceWidget.- Parameters:
request – Current request object.
It uses these Deform templates:
checkbox_choicereadonly/checkbox_choice
- class wuttaweb.forms.widgets.WuttaCheckedPasswordWidget(**kw)[source]¶
Custom widget for password+confirmation field.
This widget is used only for Vue 3 + Oruga, but is not used for Vue 2 + Buefy.
This is a subclass of
deform.widget.PasswordWidgetand uses these Deform templates:wutta_checked_password
- class wuttaweb.forms.widgets.WuttaDateTimeWidget(request, *args, **kwargs)[source]¶
Custom widget for
datetime.datetimefields.The main purpose of this widget is to leverage
render_datetime()for the readonly display.It is automatically used for SQLAlchemy mapped classes where the field maps to a
sqlalchemy.types.DateTimecolumn. For other (non-mapped) datetime fields, you may have to use it explicitly viaset_widget().This is a subclass of
deform.widget.DateTimeInputWidgetand uses these Deform templates:datetimeinput
- class wuttaweb.forms.widgets.WuttaDateWidget(request, *args, **kwargs)[source]¶
Custom widget for
datetime.datefields.The main purpose of this widget is to leverage
render_date()for the readonly display.It is automatically used for SQLAlchemy mapped classes where the field maps to a
sqlalchemy.types.Datecolumn. For other (non-mapped) date fields, or mapped datetime fields for which a date widget is preferred, useset_widget().This is a subclass of
deform.widget.DateInputWidgetand uses these Deform templates:dateinput
- class wuttaweb.forms.widgets.WuttaMoneyInputWidget(request, *args, **kwargs)[source]¶
Custom widget for “money” fields. This is used by default for
WuttaMoneytype nodes.The main purpose of this widget is to leverage
render_currency()for the readonly display.This is a subclass of
deform.widget.MoneyInputWidgetand uses these Deform templates:moneyinput
- Parameters:
request – Current request object.
scale – If this kwarg is specified, it will be passed along to
render_currency()call.