Skip to content
Star

PxSchemaForm

A fully schema-driven form engine. Renders a flat array of field definitions — text, number, date, select, checklists, and more — into a responsive grid. Powers Praxis's form builder.

Usage

Demo
Select...
Form Data: { "first_name": "", "last_name": "", "dob": "", "gender": "" }

Zod Integration

You can natively validate the schema using Zod. Just pass a zod-schema prop to the component and PxSchemaForm will internally wrap the fields inside a Vee-Validate <Form> that processes your schema safely.

ts
import { z } from 'zod';

const myZodSchema = z.object({
  first_name: z.string().min(2, "Must be at least 2 characters"),
  last_name: z.string().min(2, "Must be at least 2 characters")
});

Props

PropTypeDefaultDescription
schemarequiredFormSchemaField[]Flat array of field definitions to render.
modelValueRecord<string, any>{}Current form data, keyed by field.key. Use with v-model.
existingDataRecord<string, unknown>undefinedPre-existing values used to initialize fields not yet present in modelValue.
loadingbooleanfalsePassed down to select-type fields to show a loading state.
cleanedResultsstring[][]v-model:cleanedResults — tracks keys touched by multiselect_list fields.
calculatedNumbersany[][]v-model:calculatedNumbers — tracks fields of type calculated_number.
zodSchemaZodSchema<any>undefinedA Zod schema for automatic type-safe form validation using Vee-Validate.

FormSchemaField Interface

ts
interface FormSchemaField {
  key?: string
  label?: string
  type: 'text' | 'number' | 'integer' | 'double' | 'textarea' | 'select' | 'select_list'
      | 'multiselect_list' | 'date' | 'time' | 'checkbox' | 'row' | 'check_list'
      | 'check_list_input' | 'calculated_number' | 'divider_with_components' | 'hidden'
  required?: boolean
  value?: unknown
  placeholder?: string
  readonly?: boolean
  multiple?: boolean
  options?: unknown[]
  option_source?: { label_field?: string; value_field?: string; type?: string; search_field?: string }
  components?: FormSchemaField[]   // sub-fields for the 'row' type
  [key: string]: unknown
}

Emits

EventPayloadDescription
update:modelValueRecord<string, any>Emitted on any field change with the updated form data.
update:cleanedResultsstring[]Emitted when multiselect_list selections change.
update:calculatedNumbersany[]Emitted when calculated_number fields change.
scroll-bottomFormSchemaFieldEmitted when a select-type field's dropdown is scrolled near the bottom, for pagination.
search{ query: string, fieldKey: string }Emitted when search input changes in searchable select-list fields.

NOTE

PxSchemaForm is the most complex component in the library. See PxFormRow, PxSchemaMultiSelect, and PxGridSelect for the sub-field types rendered by the row, multiselect_list, and select_list field types, respectively.

Built with VitePress