F05

Warning

Forms and bindings

F05 — A select whose value is none of its options

The bound state starts as a value no option has, so the select shows its first option while the state holds something else.

What the compiler said

warning[F05]: `plan` starts as `basic`, which is none of this select's options --> src/App.wf:4:5 | 4 | Select(bind: plan, label: "Plan") { | ^^^^^^ = help: Start it as one of them (`free`, `pro`), so what is shown is what is held = docs: https://webfluent.monzeromer.dev/errors/F05

The fix

Broken

wf

page P(path: "/", title: "T", description: "D") { state plan = "basic" Heading("Plan").h1 Select(bind: plan, label: "Plan") { Select.Option("Free", value: "free") Select.Option("Pro", value: "pro") } }

Fixed

wf

page P(path: "/", title: "T", description: "D") { state plan = "free" Heading("Plan").h1 Select(bind: plan, label: "Plan") { Select.Option("Free", value: "free") Select.Option("Pro", value: "pro") } }

Start the state as one of the options' values.

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

Why this rule exists

Warning.

lints may lower it:

"lints": { "F05": "off" } // wf-allow(F05)