Skip to content

useFieldProps 2.0.0+ ​

Returns the props used by all field components

Usage ​

vue
<script setup>
import { toRefs } from 'vue'
import { useFieldProps } from '@kevinkosterr/vue3-form-generator'
  
const props = defineProps(useFieldProps())
  
const { field, model } = toRefs(props)
</script>

TypeScript alternative ​

vue
<script setup lang="ts">
import { toRefs } from 'vue'
import type { FieldProps, FieldBase, FieldPropRefs } from '@kevinkosterr/vue3-form-generator'

type CustomField = FieldBase & {}

const props = defineProps<FieldProps<CustomField>>()
  
const { field, model }: FieldPropRefs<CustomField> = toRefs(props)
</script>

Props ​

id String ​

Id of the field, computed based on the idPrefix set within the FormGenerator component and name property of the field.

formOptions Object ​

An object of global options for the current form.

field Object required ​

Field object as set in the schema.

model Object required ​

Model object as set in the schema, contains all current values.