{{ formData.content || 'No content yet...' }}
Current email: {{ email }}
``` -------------------------------- ### Form Setup with Async Default Values Source: https://github.com/vuehookform/core/blob/main/docs/guide/essentials/form-setup.md Demonstrates configuring `useForm` to load default values asynchronously, typically from an API. The `defaultValues` option accepts an async function that returns the initial data. Error handling for the async operation is managed via `onDefaultValuesError`. ```typescript const { formState } = useForm({ schema, defaultValues: async () => { const response = await fetch('/api/user') return response.json() }, onDefaultValuesError: (error) => { console.error('Failed to load:', error) }, }) ``` -------------------------------- ### useWatch Return Value Examples Source: https://github.com/vuehookform/core/blob/main/docs/api/use-watch.md Provides examples of the return types for useWatch when watching single fields, multiple fields, and all fields. The hook returns reactive refs containing the watched values. ```typescript // Single field const email: RefFull name: {{ fullName || 'Enter your name' }}
``` -------------------------------- ### Vue Example: Computing Derived Values Source: https://github.com/vuehookform/core/blob/main/docs/api/use-watch.md Shows how to use useWatch in conjunction with Vue's computed property to derive values based on other form fields. This example calculates a 'total' price from 'quantity' and 'unitPrice'. ```vueTotal: ${{ total.toFixed(2) }}
``` -------------------------------- ### Implement Dynamic Field Arrays in Vue Source: https://github.com/vuehookform/core/blob/main/docs/guide/dynamic/field-arrays.md Demonstrates the basic setup of a dynamic form using VueHookForm's fields API. It includes schema definition with Zod, form initialization, and rendering repeatable input fields. ```vue ``` -------------------------------- ### Share Form Context via Provide/Inject Source: https://github.com/vuehookform/core/blob/main/docs/examples/index.md Uses provideForm to share form state and methods across deeply nested component trees. ```vue ``` -------------------------------- ### Field Array Setup with Zod Schema in TypeScript Source: https://github.com/vuehookform/core/blob/main/docs/public/llms.txt Shows the setup for a field array using Vue Hook Form, including defining a Zod schema for validation and using 'fields' and 'register' to manage dynamic lists of form elements. ```typescript const schema = z.object({ items: z.array(z.object({ name: z.string().min(1), quantity: z.number().min(1) })).min(1) }) const { fields, register } = useForm({ schema, defaultValues: { items: [{ name: '', quantity: 1 }] } }) const itemFields = fields('items') ``` -------------------------------- ### Implement Dynamic Field Array with Scoped Methods Source: https://github.com/vuehookform/core/blob/main/docs/guide/dynamic/field-arrays.md A complete example of a dynamic form using @vuehookform/core, demonstrating scoped registration, error handling, and item manipulation. ```vue ``` -------------------------------- ### Implement User Registration Form with Validation Source: https://github.com/vuehookform/core/blob/main/docs/examples/index.md Demonstrates a basic registration form using Zod for schema validation. It includes a custom refinement to ensure password and confirmPassword fields match. ```vue ``` -------------------------------- ### Form Setup with Disabled State Source: https://github.com/vuehookform/core/blob/main/docs/guide/essentials/form-setup.md Shows how to disable the entire form using a reactive `ref` passed to the `disabled` option in `useForm`. When disabled, all inputs are marked with the `disabled` attribute, and form submission is prevented, which is useful during loading states. ```typescript import { ref } from 'vue' const isLoading = ref(false) const form = useForm({ schema, disabled: isLoading, // Reactive ref }) ``` -------------------------------- ### Conventional Commits for Release Management Source: https://github.com/vuehookform/core/blob/main/CLAUDE.md Examples of Git commit messages following conventional commit standards for triggering automated releases with Release Please. Covers patch, minor, and major version bumps, as well as non-release commits. ```bash # Patch release (0.3.1 → 0.3.2) git commit -m "fix: correct validation error message formatting" # Minor release (0.3.2 → 0.4.0) git commit -m "feat: add onTouched validation mode" # Major release (0.4.0 → 1.0.0) git commit -m "feat!: change register() return type" # or git commit -m "feat: new API BREAKING CHANGE: register() now returns an object instead of array" # No release triggered git commit -m "docs: update README examples" git commit -m "chore: update CI workflow" ``` -------------------------------- ### Provide and Use Form Context in Vue Source: https://github.com/vuehookform/core/blob/main/docs/examples/index.md Demonstrates how to provide a form instance to all descendant components using `provideForm` and access it in deeply nested components using `useFormContext`. This pattern avoids prop drilling in complex component trees. ```vue ``` ```vueYour message has been sent.