Skip to main content

Forms

A form class (BaseForm) defines the fields users fill in when adding or editing records. It is wired to BaseCrudView via the form attribute and rendered by FormRenderer on the frontend.

How It Fits Together

BaseCrudView
├── table = PatientTable
└── form = PatientForm ← used for Add and Edit

When a user clicks Add or an Edit row action, the view serves the form schema as JSON and the frontend renders it dynamically via FormRenderer.

What a Form Class Defines

FeatureHow
Model-mapped fieldsModelField attributes
Custom/computed fieldsCustomSchemaField
Standard Django fieldsforms.CharField, etc.
Required validationrequired=True, required_msg
Read-only fieldsreadonly=True
Hidden fieldshidden=True
Field initial valuesinitial=<value or callable>

Sections

SectionDescription
Creating a Form ClassImports, Meta, field definitions
Form FieldsModelField, CustomSchemaField, custom Django fields
Best PracticesData integrity, section layout, unique constraints
API ReferenceFull parameter reference for ModelField