Widget context from defineWidget render function
Form configuration options
Form state and control methods
const LoginForm = defineWidget<{ onLogin: (u: string, p: string) => void }>(
(props, ctx) => {
const form = useForm(ctx, {
initialValues: { username: "", password: "" },
validate: (v) => {
const errors: Record<string, string> = {};
if (!v.username) errors.username = "Required";
if (v.password.length < 8) errors.password = "Min 8 chars";
return errors;
},
onSubmit: (v) => props.onLogin(v.username, v.password),
});
return ui.column([
ui.input({
id: ctx.id("username"),
value: form.values.username,
onInput: form.handleChange("username"),
onBlur: form.handleBlur("username"),
}),
// ...
]);
}
);
Form management hook for Rezi widgets.
Provides comprehensive form state management including: