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 returned form handle around; event handlers then use the handle instead of calling useForm again.
  • For UI that must not exist until an interaction happens, mount a child component on that interaction (v-if) and let its own setup() run the composable.

The form walks the handle useForm returns and the state it carries.