Form in a Dialog
A dialog-driven invoice form in which each line item is entered through a modal that validates it against its own Zod schema before it is appended to the parent form's items array. The parent validates the client name and requires at least one item before the invoice can be submitted.


shadcn add · no workarounds · theme neutral (none shipped)Installation
Requires @flx in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { RhfAdvanced02 } from '@/components/flx/forms/react-hook-form/rhf-advanced-02'export default function Page() { return <RhfAdvanced02 />}- Collecting a list of repeated records where each entry needs its own validation before it joins the parent form
- Building invoice, order, or expense forms where line items are added one at a time in a modal
- Gating a parent form submit on a non-empty array field while keeping the item editor isolated
- Showing a clean empty state and running totals for a dynamic list inside a form
Examples
Basic invoice form on a page
Render the complete invoice builder. It takes no props and manages its own form state.
import { RhfAdvanced02 } from '@/components/flx/forms/react-hook-form/rhf-advanced-02'export default function InvoicePage() { return ( <main className='flex justify-center p-6'> <RhfAdvanced02 /> </main> )}Standalone line item dialog
Use LineItemDialog on its own and receive each validated line item through onAdd.
import { LineItemDialog, type LineItem,} from '@/components/flx/forms/react-hook-form/rhf-advanced-02-line-item-dialog'export function QuoteItemAdder() { function handleAdd(item: LineItem) { console.log(item.description, item.quantity, item.unitPrice) } return <LineItemDialog onAdd={handleAdd} />}Reusing the line item schema
Validate arbitrary input with the exported lineItemSchema, for example when importing rows from a CSV.
import { lineItemSchema } from '@/components/flx/forms/react-hook-form/rhf-advanced-02-line-item-dialog'export function ImportCheck() { const result = lineItemSchema.safeParse({ description: 'Hosting', quantity: '2', unitPrice: '19.5', }) return <p>{result.success ? 'Valid row' : 'Invalid row'}</p>}API reference
Accessibility
- Every input has a visible FieldLabel linked by htmlFor and a matching id, so screen readers announce the field name.
- Invalid inputs set aria-invalid and data-invalid, and FieldError renders the Zod message next to the field.
- The icon-only remove button has aria-label 'Remove item', and it is type='button' so it does not submit the form.
- The Add line item trigger is a real button that opens a dialog; the dialog should keep focus inside while open and return focus on close.
- Closing the dialog, including via Cancel or Escape, resets its form so no stale values persist between openings.
- The submit button is disabled while there are no items, so keyboard and screen reader users cannot submit an empty invoice.
- Decorative icons are not labeled separately; the visible text labels carry the meaning.
Docs written by anthropic:claude-haiku-5-5 from the registry source.
Use with Coding Agent
Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.
Use the "Form in a Dialog" component (flx/rhf-advanced-02) from its shadcn registry.1. Install it with: npx shadcn@latest add @flx/rhf-advanced-022. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: RhfAdvanced02, onAdd.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { RhfAdvanced02 } from '@/components/flx/forms/react-hook-form/rhf-advanced-02'export default function Page() { return <RhfAdvanced02 />}```Files & dependencies
- registry/forms/react-hook-form/advanced/rhf-advanced-02.tsx→ components/flx/forms/react-hook-form/rhf-advanced-02.tsx
- registry/forms/react-hook-form/advanced/rhf-advanced-02-line-item-dialog.tsx→ components/flx/forms/react-hook-form/rhf-advanced-02-line-item-dialog.tsx