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]¶
- Bases: - django.forms.widgets.Widget- 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. - Type: - djblets.conditions.choices.ConditionChoices 
 - 
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 - BaseConditionChoiceconstructor. 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: - dict 
 - 
template_name= u'djblets_forms/conditions_widget.html'[source]¶
- The name of the template used to render the widget. 
 - 
__init__(choices, mode_widget, choice_widget, operator_widget, choice_kwargs=None, attrs=None)[source]¶
- Initialize the widget. - Parameters: - choices (djblets.conditions.choices.ConditionChoices) – The condition choices for the field.
- mode_widget (django.forms.widgets.RadioSelect) – The widget for selecting the mode.
- choice_widget (django.forms.widgets.Select) – The widget for selecting choices. One of these will be rendered for every row.
- operator_widget (django.forms.widgets.Select) – The widget for selecting operators. One of these will be rendered for every row.
- choice_kwargs (dict) – Optional keyword arguments to pass to each
BaseConditionChoiceconstructor. This is useful for more advanced conditions that need additional data from the form.
- attrs (dict, optional) – Additional HTML element attributes for 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: 
 - 
get_context(name, value, attrs)[source]¶
- Return context for the widget. - This will serialize all the choices, operators, and existing conditions needed to render the widget. - Parameters: - Returns: - The context data for the widget. - Return type: 
 - 
__deepcopy__(memo)[source]¶
- Return a deep copy of the widget. - This will return a deep copy of this widget and all subwidgets, so that a particular form instance can easily manipulate state without affecting other instances. - Only the state that may be manipulated by an instance will be deep copied. - Parameters: - memo (dict) – The memo dictionary used to track IDs to objects. - Returns: - A deep copy of this widget’s instance. - Return type: - ConditionsWidget 
 
- 
- 
class CopyableTextInput(attrs=None)[source]¶
- Bases: - django.forms.widgets.TextInput- A TextInput widget that renders a link to copy its contents. 
- 
class ListEditWidget(attrs=None, sep=u', ')[source]¶
- Bases: - django.forms.widgets.Widget- A widget for editing a list of separated values. - 
__init__(attrs=None, sep=u', ')[source]¶
- Initialize the widget. - Parameters: - attrs (dict, optional) – The attributes of the <input>elements.
- sep (unicode, optional) – The item separator.
 
- attrs (dict, optional) – The attributes of the 
 
- 
