djblets.forms.widgets¶
Custom widgets for Django form fields.
This module contains widgets that correspond to fields provided in
djblets.forms.fields
.
- class ConditionsWidget(choices, mode_widget, choice_widget, operator_widget, choice_kwargs=None, attrs=None)[source]¶
A widget used to request a list of conditions from the user.
This is used by
ConditionsField()
to allow the user to specify a list of possible conditions, composed of choices, operators, and values.The conditions are displayed as rows of fields. Each row contains a
<select>
for the condition choice, operator choice, and a choice-provided field for a value.Additional conditions can be added by the user dynamically.
- choices¶
The condition choices for the field.
- mode_widget¶
The widget for selecting the mode.
- Type
django.forms.widgets.RadioSelect
- choice_widget¶
The widget for selecting choices. One of these will be rendered for every row.
- Type
django.forms.widgets.Select
- operator_widget¶
The widget for selecting operators. One of these will be rendered for every row.
- Type
django.forms.widgets.Select
- choice_kwargs¶
Optional keyword arguments to pass to each
BaseConditionChoice
constructor. This is useful for more advanced conditions that need additional data from the form.This can be updated dynamically by the form during initialization.
- Type
- template_name = 'djblets_forms/conditions_widget.html'[source]¶
The name of the template used to render the widget.
- value_from_datadict(data, files, name)[source]¶
Return a value for the field from a submitted form.
This serializes the data POSTed for the form into a format that the field can use and validate.
- Parameters
data (django.http.request.QueryDict) – The dictionary containing form data.
files (django.http.request.QueryDict) – The dictionary containing uploaded files.
name (unicode) – The field name for the value to load.
- Returns
The value from the form data.
- Return type
- render(name, value, attrs=None)[source]¶
Render the widget to HTML.
This will serialize all the choices, operators, and existing conditions and render an HTML representation, along with setting up JavaScript support for configuring the conditions.
- Parameters
- Returns
The rendered HTML for the widget.
- Return type
- class CopyableTextInput(attrs=None)[source]¶
A TextInput widget that renders a link to copy its contents.
- class ListEditWidget(attrs=None, sep=',')[source]¶
A widget for editing a list of separated values.
- class RelatedObjectWidget(multivalued=True)[source]¶
A base class form widget that lets people select one or more objects.
This is a base class. Extended classes must define their own render() method, to render their own widget with their own data.
This should be used with relatedObjectSelectorView.es6.js, which extends a Backbone view to display data.