You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 7, 2026. It is now read-only.
Closes#160. Adds two new form field components:
- FormFieldRadio: renders a string-Enum/Literal field as a radio button
group. Triggered by `Radio()` (or json_schema_extra={"format": "radio"})
on the Pydantic field. Supports `inline` for horizontal layout.
- FormFieldToggle: dedicated on/off switch component. Triggered by
`Toggle()` (or json_schema_extra={"format": "toggle"}). Optional
on_label / off_label render next to the switch.
Multi-value fields (list[Enum]) annotated with Radio() fall back to the
existing select component, since radios can't represent multi-select.
Frontend:
- src/npm-fastui/src/components/FormField.tsx: new FormFieldRadioComp
and FormFieldToggleComp following the existing FormFieldBooleanComp /
FormFieldSelectVanillaComp patterns. Pre-computes useClassName values
to satisfy react-hooks/rules-of-hooks.
- src/npm-fastui/src/components/index.tsx: wires the new types into the
AnyComp switch.
- src/npm-fastui/src/models.d.ts: matching TypeScript interfaces.
- src/npm-fastui-bootstrap/src/index.tsx: Bootstrap classNameGenerator
cases for `form-check`, `form-switch`, radio sub-elements.
- src/npm-fastui-bootstrap/src/Radio.tsx, Toggle.tsx: thin re-export
wrappers (matches the layout of modal.tsx / navbar.tsx).
Python:
- src/python-fastui/fastui/components/forms.py: FormFieldRadio /
FormFieldToggle Pydantic models with `type` discriminator.
- src/python-fastui/fastui/forms.py: Radio() / Toggle() helper
functions that mirror the existing Textarea() helper.
- src/python-fastui/fastui/json_schema.py: dispatch on format='radio'
(string + enum) and format='toggle' (boolean). Also preserve outer
`format` keys when dereferencing $ref so per-field overrides survive.
Tests:
- src/python-fastui/tests/test_forms.py: 5 new tests covering radio
field schema output, radio submit, invalid value, toggle schema
output, and the multi-radio fallback to select.
0 commit comments