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
| Feature | How |
|---|---|
| Model-mapped fields | ModelField attributes |
| Custom/computed fields | CustomSchemaField |
| Standard Django fields | forms.CharField, etc. |
| Required validation | required=True, required_msg |
| Read-only fields | readonly=True |
| Hidden fields | hidden=True |
| Field initial values | initial=<value or callable> |
Sections
| Section | Description |
|---|---|
| Creating a Form Class | Imports, Meta, field definitions |
| Form Fields | ModelField, CustomSchemaField, custom Django fields |
| Best Practices | Data integrity, section layout, unique constraints |
| API Reference | Full parameter reference for ModelField |