Skip to content

<Enforma/> API

Props

PropTypeDescription
dataObjectThe form data object
schemaObjectOptional form schema for schema-based rendering
validatorFormValidatorValidator instance (created with createEncolaValidator, createZodValidator, etc.)
submitHandlerFunctionFunction to be called on submit
configObjectForm configuration options
showResetButtonBooleanTo show the reset button (default true)
showSubmitButtonBooleanTo show the submit button (default true). This is useful if you want to place the submit button outside the form
rulesObjectDEPRECATED: Use validator prop instead
messagesObjectDEPRECATED: Use validator prop instead

DEPRECATED PROPS

The :rules and :messages props are deprecated in v1.3.0. Use the :validator prop with a validator factory function instead:

vue
<script setup>
import { createEncolaValidator } from '@encolajs/enforma/validators/encola'

const validator = createEncolaValidator(
  { firstName: 'required', email: 'required|email' },
  { 'firstName.required': 'First name is required' }
)
</script>
<template>
  <Enforma :data="formData" :validator="validator" />
</template>

See the Migration Guide for complete migration instructions.

Events

EventPayloadDescription
submit_errorformDataEmitted when there's an error while submitting the form
submit_successformDataEmitted when the form is successfully submited
validation_fail{ formController }Emitted when validation fails. This is where you add notifications/toasts or scroll the form to the first field
validation_successformDataEmitted when validation passes
field_change{ path, value, fieldController, formController }Emitted when any field value changes
field_blur{ name, fieldController, formController }Emitted when a field is blurred
field_focus{ name, fieldController, formController }Emitted when a field is focused

Slots

SlotPropsDescription
defaultNoneThe main slot for form content where the fields are being rendered
actionsNoneThe place where the submit and reset buttons are being rendered

Released under the MIT License