Forms
Use form-associated fields with name, FormData, VuForm, and v-model across frameworks.
Before you begin
- Packages installed for your stack (see Installation)
- App wrapped in
VuThemeProvider/vu-theme-provider
Form-associated fields
Many Velkin fields are form-associated custom elements. Give them a name, put them in a form, and they participate in FormData, validation, and reset like native controls.
- Set
nameso the control submits with the form - Use
value/checkedfor controlled UI, ordefaultValue/defaultCheckedfor reset behavior - Prefer documented validity APIs (
checkValidity,reportValidity) and field props likerequired/showErrors - Prefer
VuFormwhen you want integrated validation andvu-submit— native<form>still works
Across frameworks
import { VuForm } from "@velkin/react/form";
import { VuInput } from "@velkin/react/input";
import { VuButton } from "@velkin/react/button";
<VuForm
onVuSubmit={(e) => {
e.preventDefault();
const data = new FormData(e.target as HTMLFormElement);
console.log(Object.fromEntries(data.entries()));
}}
>
<VuInput name="email" label="Email" type="email" required showErrors />
<VuButton type="submit" color="primary">
Continue
</VuButton>
</VuForm>Common problems
| Problem | Fix |
|---|---|
| Field missing from submit payload | Set name on the field |
Listening for native submit on VuForm | Use onVuSubmit / @vu-submit |
| Controlled value not updating | Wire onVuChange + e.detail, or Vue v-model:* |