StoicBuilder

HandbookII the ForumForms

IIthe Forum, The shape of an app

Forms

1 min readUpdated 28 November

In plain words

A form gathers what a person types or picks, checks it, and sends it to the server, which checks it again and saves it.

Where you see it

QuickBite's delivery address form, or Guildhall's profile editor. You press Save, the button greys out, and either a confirmation appears or the fields turn red.

components/ProfileForm.tsxbrowser
async function onSubmit(e: React.FormEvent<HTMLFormElement>) { e.preventDefault(); // stop the browser reloading the page setSaving(true); const body = JSON.stringify(Object.fromEntries(new FormData(e.currentTarget))); const res = await fetch("/api/profile", { method: "POST", headers: { "Content-Type": "application/json" }, body }); setSaving(false); setMessage(res.ok ? "Saved" : "Couldn't save. Your text is still here, try again.");}
Stop the reload, disable the button while saving, and always tell the person what happened.

What goes wrong

  1. Losing what someone typed

    A long bio kept only in state vanishes if the tab reloads or the form resets after a failed save. Keep the text on screen after an error, and save drafts of long forms in the browser.

  2. Checking only in the browser

    Attributes like required and maxLength only stop honest users. Anyone can send the request directly, so the server must check everything again.

  3. Double submits

    If the button stays active while saving, an impatient second tap places a second QuickBite order. Disable it until the reply arrives.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
For this form, validate input in the browser and again on the server, disable the submit button while saving, keep what the user typed if saving fails, and show a clear message for success and for each error.

Quick check

Sign in to earn +10 XP for it

A customer was charged twice for one QuickBite order, two seconds apart. How did that happen?

Got a prompt that touches forms?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.