Skip to main content

Value and selection widgets

Value and selection widgets (dark theme)
Value and selection widgets (light theme)

Drag the divider or use the arrow keys to compare themes.

Value and selection widgets
Value and selection widgets (dark theme)
Value and selection widgets (light theme)

Drag the divider or use the arrow keys to compare themes.

  1. Copy a value together with its visible prefix
  2. Change a typed boolean value with the switch
  3. See the unit beside an integer input
  4. Move available choices to the selected list
Value and selection widgets

Django Chassis 1.0.23 · training site with Russian UI

  1. Copy a value together with its visible prefix
  2. Change a typed boolean value with the switch
  3. See the unit beside an integer input
  4. Move available choices to the selected list

How to add it​

Add these fields to the WidgetGalleryForm in catalog_demo/widget_gallery_form.py. In its Admin template, render the fields inside a form and load admin/css/widgets.css, the Admin JavaScript catalog, and {{ gallery.media }} so the two-list selector can initialize.

from django import forms
from django_chassis.widgets import BooleanChoiceSwitch, CopyableTextInput, TransferSelect, UnitInput

class WidgetGalleryForm(forms.Form):
code = forms.CharField(initial='001', widget=CopyableTextInput(prefix='LAB-'))
enabled = forms.TypedChoiceField(
choices=[(True, 'Да'), (False, 'Нет')], initial=True,
coerce=lambda value: value == 'True', widget=BooleanChoiceSwitch(),
)
quota = forms.IntegerField(initial=35, widget=UnitInput('операций/мин'))
checkpoints = forms.MultipleChoiceField(
choices=[('power', 'Питание'), ('network', 'Связь'), ('print', 'Печать')],
initial=['power'], widget=TransferSelect(verbose_name='проверки'),
)

Try copying LAB-001, toggling the switch and moving a choice. In the form data, the code field still contains 001.