Skip to content

Commit 6a0d1ea

Browse files
committed
Update CHANGELOG and README for upcoming release
Add radio, checkbox collections, unique DOM ids, select improvements, and preview server to unreleased changelog. Update README field guide with unique id examples and label association patterns.
1 parent 3cfa9a8 commit 6a0d1ea

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
## [Unreleased]
22

3+
### Added
4+
5+
- **Radio component** with `field(:gender).radio("male")` API. Automatically handles name, value, and checked state. Each radio gets a unique DOM id based on its value (e.g. `user_gender_male`).
6+
- **Checkbox collection support** — three modes:
7+
- **Boolean** (on/off toggle): `Field(:featured).checkbox` renders with hidden "0" input
8+
- **All-options** (pick from known set): `Field(:role_ids).checkbox(value: role.id)` with `[]` name and unique ids per value
9+
- **Field collection** (from existing array): `field(:role_ids).collection { |r| r.checkbox }` for values already on the model
10+
- **Unique DOM ids** for radio and checkbox groups via `DOM#id(*suffixes)`. Prevents duplicate ids in valid HTML and allows labels to target individual inputs.
11+
- **Select improvements**: blank options (`nil`) at any position, `multiple: true` support with hidden input for empty submissions, ActiveRecord relations as options.
12+
- **Preview server** — run `bin/preview` to view example forms at localhost:3000 with hot-reloading.
13+
314
### Changed
415

516
- **Deprecation**: Components now accept HTML attributes as keyword arguments directly instead of wrapping them in `attributes:`. The old `attributes:` keyword still works but emits a deprecation warning and will be removed in a future version.
@@ -32,6 +43,8 @@
3243
end
3344
```
3445

46+
- Required Ruby version bumped to 2.7.0.
47+
3548
## [0.6.1] - 2025-08-28
3649

3750
### Breaking Changes

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,12 @@ class SignupForm < Components::Form
407407
end
408408

409409
# Checkbox groups: loop over all possible options. Superform handles
410-
# the name (with []), value, and checked state. You control the HTML.
410+
# the name (with []), value, checked state, and unique ids. Each
411+
# checkbox gets an id like "role_ids_1", "role_ids_2", etc.
411412
fieldset do
412413
legend { "Roles" }
413414
Role.all.each do |role|
414-
label do
415+
label(for: "#{field(:role_ids).dom.id}_#{role.id}") do
415416
Field(:role_ids).checkbox(value: role.id)
416417
whitespace
417418
plain role.name
@@ -420,11 +421,12 @@ class SignupForm < Components::Form
420421
end
421422

422423
# Radio groups: iterate your options and call radio(value) on the field.
423-
# Superform handles the name, value, and checked state automatically.
424+
# Superform handles the name, value, checked state, and unique ids automatically.
425+
# Each radio gets an id like "plan_id_1", "plan_id_2", etc.
424426
fieldset do
425427
legend { "Plan" }
426428
Plan.all.each do |plan|
427-
label do
429+
label(for: "#{field(:plan_id).dom.id}_#{plan.id}") do
428430
Field(:plan_id).radio(plan.id)
429431
whitespace
430432
plain plan.name

0 commit comments

Comments
 (0)