melony.dev

formView

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

Example:

export const createProjectFormView = formView({
  action: createProjectAction,
  title: "Create Project",
  fields: {
    title: textField(),
    amount: numberField({
      label: "Amount",
      description: "Grand amount of the current project.",
    }),
    // ... other fields ...
  },
});

FormView Key Properties:

  • action: Server action or endpoint string.
  • 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