Skip to content
TroubleshootingCoreFix two components sharing a name.

Two components share a name

The error

The page returned from save has multiple components with the same
name:
  'answer' is used by: TextBox, SelectBox
Each component must have a unique name, because the name is how
values are matched to route parameters. Rename the duplicates.

The friendly title is "Components Share a Name".

What it means

Two or more inputs on one page use the same name. Names are how submitted values are matched to route parameters. If two components shared one name, one value would silently overwrite the other, so Drafter stops the page instead of guessing which one you meant.

Where to look

Start with the route named in the message. Search its content list for the quoted name; the message lists which component types are using it.

Check

  • A copy-paste mistake: a line containing TextBox("answer") was duplicated, and the copy was never renamed.
  • Two questions, one name: two genuinely different inputs (TextBox("answer") and SelectBox("answer", ...)) that each deserve their own parameter.
  • A checkbox group on purpose: several checkboxes meant to submit together should be RelatedCheckBox, which is designed to share one name (and delivers a list).

Fix

Rename so each input has its own name, with a matching parameter on the receiving route:

TextBox("guess"),
SelectBox("category", ["animals", "history"]),
Button("Submit", "save")
@route
def save(state: State, guess: str, category: str) -> Page:
    ...

Confirm

The page renders again, and submitting fills both parameters. An assert_has(index(state), TextBox("guess")) keeps the rename from quietly regressing.

Prevent

Name inputs after the specific question they ask (pet_name, pet_age), not after generic slots (input1, answer). Specific names rarely collide.

Understand

Forms and input explains the name-to-parameter contract that this uniqueness rule protects.