Skip to content

useFormBaseLogic ​

Core logic for the FormBase component — flattens nested schema sections, binds schema fields to the model, and manages drag-and-drop reordering, cascade selects, and grid layout attributes.

File: vue/src/js/hooks/useFormBaseLogic.js


Usage ​

js
import { useFormBaseLogic } from '@/hooks'

const {
  flatCombinedArray,
  flatCombinedArraySorted,
  bindSchema,
  onInput,
  mapTypeToComponent,
  getGridAttributes,
} = useFormBaseLogic(props, context)

Returns ​

Computed ​

NameTypeDescription
flatCombinedArrayComputedRef<Array>Flat list of all schema fields across all sections, in declaration order
flatCombinedArraySortedComputedRef<Array>Same list sorted by sidebarPos / order, respecting drag-and-drop overrides

Methods ​

NameSignatureDescription
bindSchema(field, model) => ObjectMerges a schema field definition with the current model value, returning a fully bound field object ready for an input component
onInput(key, value) => voidPropagates a field value change upward to the parent form and triggers cascade-select resolution
mapTypeToComponent(type: String) => StringResolves a schema field type string (e.g. 'text', 'select', 'repeater') to its corresponding Vue component name
getGridAttributes(field) => ObjectReturns Vuetify grid props (cols, sm, md, lg) for a schema field based on its grid config

Drag-and-Drop ​

NameTypeDescription
dragstartFunctiondragstart event handler — marks the dragged field
dragoverFunctiondragover event handler — allows drop
dropFunctiondrop event handler — reorders flatCombinedArraySorted

Cascade Selects ​

When a field has cascade configured, onInput automatically fetches the dependent field's options from the server whenever the parent field value changes.

Slot Name Generators ​

useFormBaseLogic exports helper functions used by FormBase to generate slot names for custom field rendering:

js
// e.g. for a field with key "user_id":
slotName(field)        // → 'field.user_id'
headerSlotName(field)  // → 'header.user_id'

See Also ​