Skip to content

Commit 703797f

Browse files
committed
Release 0.5.0: excludes, save_data(), and built-in styles
Forms are subtractive with scoped excludes. save_data() returns a dict ready for MyModel.create(). default_css() ships a stylesheet. CSRF simplified to a pre-check. includes removed.
1 parent 04b3d52 commit 703797f

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

CHANGELOG/0.5.0.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## AirForm 0.5.0: Excludes, save_data(), and built-in styles
2+
3+
Forms start with all fields and subtract what they don't need. `excludes` controls what renders and what saves, with scoped tuples for fine-grained control. `save_data()` returns a dict ready for `await MyModel.create()`. And `default_css()` makes forms look good without a CSS framework.
4+
5+
```sh
6+
uv add AirForm --upgrade
7+
```
8+
9+
### What's new
10+
11+
- **Scoped excludes.** A bare string like `"created_at"` hides the field from both rendering and saving. A tuple like `("finish", "display")` hides it from the form but keeps it in `save_data()`. PrimaryKey fields are display-excluded by default.
12+
13+
```python
14+
class ArticleForm(AirForm[Article]):
15+
excludes = ("created_at", ("slug", "display"))
16+
```
17+
18+
- **`save_data()` method.** Returns `form.data.model_dump()` minus save-excluded fields. The pattern for database persistence is now one line:
19+
20+
```python
21+
await Article.create(**form.save_data())
22+
```
23+
24+
- **`default_css()` built-in stylesheet.** AirForm ships CSS that styles every element it renders: field layout, input borders, focus rings, error states, help text, and checkbox alignment. Load it with `airform.default_css()`.
25+
26+
### What's changed
27+
28+
- **`includes` is removed.** Forms are subtractive only. Use `excludes` to hide fields instead of `includes` to show them. Custom widgets that accepted an `includes` parameter should accept `excludes` instead.
29+
30+
- **CSRF validation simplified.** The Pydantic wrapper model is replaced with a pre-check that pops the token and verifies the HMAC before Pydantic runs. `form.data` is now a properly validated instance of the user's model with all their validators run.
31+
32+
### Contributors
33+
34+
[@audreyfeldroy](https://github.com/audreyfeldroy) (Audrey M. Roy Greenfeld) built this release.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "AirForm"
7-
version = "0.4.1"
7+
version = "0.5.0"
88
description = "Pydantic-native form validation and rendering. Define a model, get a validated, rendered HTML form. Works with or without Air web framework."
99
readme = "README.md"
1010
authors = [

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)