Skip to content
On this page

Form

Props

PropTypeDescriptionRequired
serviceCRUD, SimpleCRUDObject of the service to be used for the submit event, can be crud or simpleCrudyes
optionsFormOptionsoptions with fields used for build the formyes
titlestringArray that define the columns of your list. Requires to be as { text: "Name",key: "name" }no

Usage

<Form
  v-if="service"
  title="My Form"
  :service="service"
  :options="formOptions"
/>

Example of Options:

 {
      title: "Create form",
      onSuccess: () => {
        alert("Success");
      },
      onError: (err) => {
        console.log(err);
      },
      fields: [
        {
          id: "name",
          type: "text",
          validations: ["required", "maxlength:120", "minlength:10"],
          label: "Name",
        },
        {
          id: "age",
          type: "number",
          validations: ["required", "minvalue:12"],
          label: "Age",
        },
      ],
    },

Interfaces

Form Options

interface FormOptions {
  title?: string
  fields: FieldOptions[]
  validate?: () => void;
  onSuccess?: () => void;
  onError?: () => void;
  onCancel?: () => void;
  onSubmit?: () => void;
}