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:

class wuttaweb.forms.widgets.FileDownloadWidget(request, *args, **kwargs)[source]

Widget for use with FileDownload fields.

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.Widget and 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.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.TextAreaWidget and uses these Deform templates:

  • textarea

  • readonly/notes

class wuttaweb.forms.widgets.ObjectRefWidget(request, url=None, *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; via widget_maker().

In readonly mode, this renders a <span> tag around the model_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.SelectWidget and uses these Deform templates:

  • select

  • readonly/objectref

model_instance

Reference to the model record instance, i.e. the “far side” of the foreign key relationship.

Note

You do not need to provide the model_instance when constructing the widget. Rather, it is set automatically when the ObjectRef type instance (associated with the node) is serialized.

class wuttaweb.forms.widgets.PermissionsWidget(request, session=None, *args, **kwargs)[source]

Widget for use with Role permissions field.

This is a subclass of WuttaCheckboxChoiceWidget. It uses these Deform templates:

  • permissions

  • readonly/permissions

class wuttaweb.forms.widgets.RoleRefsWidget(request, session=None, *args, **kwargs)[source]

Widget for use with User roles field. This is the default widget for the RoleRefs type.

This is a subclass of WuttaCheckboxChoiceWidget.

class wuttaweb.forms.widgets.UserRefsWidget(request, session=None, *args, **kwargs)[source]

Widget for use with Role users field. This is the default widget for the UserRefs type.

This is a subclass of WuttaCheckboxChoiceWidget; however it only supports readonly mode and does not use a template. Rather, it generates and renders a Grid showing the users list.

class wuttaweb.forms.widgets.WuttaCheckboxChoiceWidget(request, session=None, *args, **kwargs)[source]

Custom widget for set fields.

This is a subclass of deform.widget.CheckboxChoiceWidget, but adds Wutta-related params to the constructor.

Parameters:

It uses these Deform templates:

  • checkbox_choice

  • readonly/checkbox_choice