melony.dev

FormView

FormView is used for creating and editing individual records. It generates a form based on the defined fields.

Example:

export const projectCreateView = defineView(
  "form", // Type
  {
    // Config
    title: "Create Project",
    fields: {
      title: { label: "Title" },
      amount: {
        label: "Amount",
        type: "number",
        description: "Grand amount of the current project.",
      },
      // ... other fields ...
    },
  },
  createProjectAction // Action
);

FormView Key Properties:

  • title: The title of the form.
  • fields: Defines the form fields, their types, and properties.
  • isDocRequired: (For edit forms) Whether the form requires existing data to load.
  • getDefaultValues: (For edit forms) Action to fetch existing data for the form.

On this page