Skip to content

Getting Form Context in Components

When FormCreate generates custom components, it automatically injects some useful parameters into the component. You can access them through props.formCreateInject.

Property Description

Property NameTypeDescription
apiObjectForm API instance
formFunctionForm creation function
slotsFunctionGet form slots
optionsArrayrule.options configuration options
childrenArrayChild element array
previewbooleanPreview mode flag
idstring/NumberUnique identifier
inputbooleanWhether it is a form component
fieldstringForm field name
ruleObjectForm rule configuration
tFunctionMulti-language translation function

Getting Context

In custom components, get form context information through the formCreateInject property, enabling components to access the form's API instance, data state, etc., achieving deep integration and interaction with the form.

vue
<script>
  export default defineComponent({
    props: {
      formCreateInject: Object
    }
  })
</script>

Using in Setup

vue
<script setup>
  const props = defineProps({formCreateInject: Object});
</script>

By mastering the generation and operation methods of custom components above, you can implement almost any complex form requirements in FormCreate. Whether it's a simple button or complex dynamic form items.

FormCreate is an open-source project released under the MIT License. Free for personal and commercial use.