Skip to content

Commit 4b01d8c

Browse files
committed
docs: clarify value attribute on radio/checkbox inputs is allowed with formField
1 parent 71bb19d commit 4b01d8c

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

skills/dev-skills/angular-developer/references/signal-forms.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,20 @@ Do _NOT_ bind the `name` field.
170170
When using `[formField]`, you MUST NOT set the following attributes in the template (either static or bound):
171171

172172
- `min`, `max` (Use validators in the schema instead)
173-
- `value`, `[value]`, `[attr.value]` (Already handled by `[formField]`)
173+
- `value`, `[value]`, `[attr.value]` on **text/number/date inputs** (Already handled by `[formField]`)
174174
- `[attr.min]`, `[attr.max]`
175175
- `[disabled]`, `[readonly]` (Already handled by `[formField]`)
176176

177+
**Exception**: Static `value` on `<input type="radio">` and `<input type="checkbox">` is **allowed and required** — it identifies which option the input represents, not the bound field value.
178+
179+
```html
180+
<!-- CORRECT: value on radio specifies which option this button represents -->
181+
<input type="radio" value="economy" [formField]="bookingForm.package.tier" />
182+
183+
<!-- WRONG: value binding on a regular input -->
184+
<input [value]="someVar" [formField]="form.name" />
185+
```
186+
177187
Do NOT do this: `<input min="1" [formField]>` or `<input [value]="val" [formField]>`.
178188

179189
```html
@@ -520,7 +530,7 @@ form(
520530
| **Multi-select array** | `<select [formField]="form.tags">` (string[]) | Use checkboxes for array fields |
521531
| **readonly attribute** | `<input readonly [formField]>` | Use `readonly()` rule in schema |
522532
| **min/max attributes** | `<input min="1" max="10">` | Use `min()` and `max()` rules in schema |
523-
| **value binding** | `<input [value]="val">` | Do NOT use `[value]` with `[formField]` |
533+
| **value binding** | `<input [value]="val">` | Do NOT use `[value]` with `[formField]` (static `value` on radio/checkbox is OK) |
524534
| **when option** | `pattern(p.x, /.../, {when: ...})` | `when` only works with `required()` |
525535
| **Submit callback** | `submit(form, () => { ... })` | `submit(form, async () => { ... })` |
526536
| **Async params** | `params: s.field` | `params: ({ value }) => value()` |

0 commit comments

Comments
 (0)