AF06
useForm / injectForm ran outside a Vue setup() context.
In development this reads:
attaform useForm / injectForm called outside Vue setup(). Move into setup or mount a child component to trigger from an event.
What happened
Both composables register lifecycle hooks and provide/inject links, which Vue only wires while a component's setup() is running. A call from an event handler, a watcher body, or an awaited continuation has no current instance to attach to.
How to fix it
- Call the composable during
setup()and keep the returnedformhandle around; event handlers then use the handle instead of callinguseFormagain. - For UI that must not exist until an interaction happens, mount a child component on that interaction (
v-if) and let its ownsetup()run the composable.
The form walks the handle useForm returns and the state it carries.