Skip to main content

Form widgets

Added in 1.0.18

CopyableTextInput

CopyableTextInput renders an editable text input, an optional visible prefix, and the standard Chassis copy button. The button copies the configured prefix plus the input's current value. The prefix is rendered outside the HTML input, so Django receives and saves only the value entered into the field.

from django import forms

from django_chassis.widgets import CopyableTextInput


class PersonForm(forms.Form):
phone = forms.CharField(
widget=CopyableTextInput(
prefix='+375',
attrs={
'autocomplete': 'tel-national',
'inputmode': 'numeric'
}
)
)

The shared Chassis Admin base template already loads the copy client and component styles. Use the widget on a page rendered through Chassis Admin.