Home / Function/ complexFormAction() — ui Function Reference

complexFormAction() — ui Function Reference

Architecture documentation for the complexFormAction() function in form-next-complex-action.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  77b2e313_f884_3f93_b3dc_a0fadc6cd68f["complexFormAction()"]
  a48cc779_ad07_39b5_2ccd_6c96646a048d["form-next-complex-action.ts"]
  77b2e313_f884_3f93_b3dc_a0fadc6cd68f -->|defined in| a48cc779_ad07_39b5_2ccd_6c96646a048d
  style 77b2e313_f884_3f93_b3dc_a0fadc6cd68f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/registry/new-york-v4/examples/form-next-complex-action.ts lines 5–37

export async function complexFormAction(
  _prevState: FormState,
  formData: FormData
) {
  // Sleep for 1 second
  await new Promise((resolve) => setTimeout(resolve, 1000))

  const values = {
    plan: formData.get("plan") as FormState["values"]["plan"],
    billingPeriod: formData.get("billingPeriod") as string,
    addons: formData.getAll("addons") as string[],
    emailNotifications: formData.get("emailNotifications") === "on",
  }

  const result = formSchema.safeParse(values)

  if (!result.success) {
    return {
      values,
      success: false,
      errors: result.error.flatten().fieldErrors,
    }
  }

  // Do something with the values.
  // Call your database or API here.

  return {
    values,
    errors: null,
    success: true,
  }
}

Subdomains

Frequently Asked Questions

What does complexFormAction() do?
complexFormAction() is a function in the ui codebase, defined in apps/v4/registry/new-york-v4/examples/form-next-complex-action.ts.
Where is complexFormAction() defined?
complexFormAction() is defined in apps/v4/registry/new-york-v4/examples/form-next-complex-action.ts at line 5.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free