F02

Error

Forms and bindings

F02 — A bind: to a state the control cannot hold

A text field holds text, a number field (.number) a number, a checkbox a Bool. Bound to a state of another type, it writes the wrong kind of value into it.

What the compiler said

error[F02]: `bind:` on `Input` holds a `String`, but `qty` is `Number` --> src/App.wf:4:11 | 4 | Input(bind: qty, label: "Quantity") | ^^^^^^^^^ = help: A number field is `Input(…).number`, which holds a number = docs: https://webfluent.monzeromer.dev/errors/F02

The fix

Broken

wf

page P(path: "/", title: "T", description: "D") { state qty = 1 Heading("Order").h1 Input(bind: qty, label: "Quantity") }

Fixed

wf

page P(path: "/", title: "T", description: "D") { state qty = 1 Heading("Order").h1 Input(bind: qty, label: "Quantity").number }

A number field is Input(…).number; a text field holds a String.

Each example is a whole program: it is all of src/App.wf in a project with no other .wf file (trying an example).

lints cannot lower it: it would ship a broken page.