Top Related Projects
Quick Overview
Vue-form-generator is a powerful and flexible form generator component for Vue.js. It allows developers to create complex forms with minimal effort by defining a schema object that describes the form's structure and fields. The library supports a wide range of field types and provides built-in validation and customization options.
Pros
- Easy to use and integrate with existing Vue.js projects
- Highly customizable with support for custom field types and templates
- Built-in validation system with support for custom validation rules
- Responsive design and mobile-friendly out of the box
Cons
- Learning curve for complex form configurations
- Limited documentation for advanced use cases
- Some users report performance issues with large forms
- Dependency on Vue.js limits its use in other frameworks
Code Examples
- Basic form setup:
<template>
<vue-form-generator :schema="schema" :model="model" :options="formOptions">
</vue-form-generator>
</template>
<script>
import VueFormGenerator from "vue-form-generator";
export default {
components: {
"vue-form-generator": VueFormGenerator.component
},
data() {
return {
model: {},
schema: {
fields: [
{
type: "input",
inputType: "text",
label: "Name",
model: "name",
required: true
},
{
type: "submit",
buttonText: "Submit",
onSubmit: this.onSubmit
}
]
},
formOptions: {
validateAfterLoad: true,
validateAfterChanged: true
}
};
},
methods: {
onSubmit() {
console.log("Form submitted!", this.model);
}
}
};
</script>
- Custom field type:
import VueFormGenerator from "vue-form-generator";
VueFormGenerator.validators.customValidator = function(value, field, model) {
if (value.length < 3) {
return ["The field must have at least 3 characters!"];
}
};
let customField = {
template: "<input class='form-control' v-model='value'>",
mixins: [VueFormGenerator.abstractField]
};
VueFormGenerator.component.components["customField"] = customField;
- Nested schema:
schema: {
fields: [
{
type: "object",
label: "Address",
model: "address",
schema: {
fields: [
{
type: "input",
inputType: "text",
label: "Street",
model: "street"
},
{
type: "input",
inputType: "text",
label: "City",
model: "city"
}
]
}
}
]
}
Getting Started
-
Install the package:
npm install vue-form-generator
-
Import and use in your Vue component:
import VueFormGenerator from "vue-form-generator"; import "vue-form-generator/dist/vfg.css"; export default { components: { "vue-form-generator": VueFormGenerator.component }, // ... rest of your component code }
-
Define your schema and model in the component's data:
data() { return { model: {}, schema: { fields: [ // Define your form fields here ] } }; }
-
Use the component in your template:
<vue-form-generator :schema="schema" :model="model"></vue-form-generator>
Competitor Comparisons
Vue Forms ⚡️ Supercharged
Pros of FormKit
- More modern and actively maintained, with regular updates and a growing community
- Comprehensive documentation and extensive examples for various form scenarios
- Built-in validation system with pre-defined rules and custom validation support
Cons of FormKit
- Steeper learning curve due to its more complex architecture and concepts
- Requires a paid license for commercial use, unlike the open-source vue-form-generator
Code Comparison
vue-form-generator:
<vue-form-generator :schema="schema" :model="model" :options="formOptions"></vue-form-generator>
FormKit:
<FormKit type="form" :actions="false" v-model="formData">
<FormKit type="text" name="username" label="Username" />
<FormKit type="password" name="password" label="Password" />
</FormKit>
Key Differences
- FormKit offers a more declarative approach to form building, with each field as a separate component
- vue-form-generator uses a schema-based approach, defining the entire form structure in a single object
- FormKit provides more granular control over individual form elements and their behavior
- vue-form-generator is generally easier to set up for simple forms but may be less flexible for complex scenarios
Both libraries aim to simplify form creation in Vue applications, but FormKit offers a more modern and feature-rich approach at the cost of increased complexity and potential licensing fees for commercial use.
Simple, lightweight model-based validation for Vue.js
Pros of Vuelidate
- Lightweight and flexible validation library
- Model-based validation approach
- Easy integration with existing Vue projects
Cons of Vuelidate
- Requires more manual setup for complex forms
- Less out-of-the-box UI components
- Steeper learning curve for beginners
Code Comparison
Vuelidate:
import { required, minLength } from 'vuelidate/lib/validators'
export default {
validations: {
name: { required, minLength: minLength(4) }
}
}
Vue Form Generator:
export default {
schema: {
fields: [{
type: "input",
inputType: "text",
label: "Name",
model: "name",
min: 4,
required: true
}]
}
}
Key Differences
- Vuelidate focuses on validation logic, while Vue Form Generator provides a complete form generation solution
- Vue Form Generator offers pre-built UI components, whereas Vuelidate requires custom UI implementation
- Vuelidate provides more granular control over validation rules, while Vue Form Generator simplifies form creation with a schema-based approach
Use Cases
- Choose Vuelidate for projects requiring custom form layouts and complex validation logic
- Opt for Vue Form Generator when rapid form development and pre-built UI components are priorities
Community and Maintenance
- Both projects have active communities and regular updates
- Vuelidate has a larger user base and more frequent releases
- Vue Form Generator offers extensive documentation and examples
Open-Source Form Framework for Vue
Pros of Vueform
- More comprehensive and feature-rich form builder
- Better documentation and examples
- Active development and regular updates
Cons of Vueform
- Steeper learning curve due to more complex API
- Larger bundle size and potentially higher performance overhead
Code Comparison
Vue Form Generator:
<vue-form-generator :schema="schema" :model="model" :options="formOptions"></vue-form-generator>
Vueform:
<Vueform :schema="schema">
<VField name="email" />
<VField name="password" />
<VButton>Submit</VButton>
</Vueform>
Key Differences
-
API Approach: Vue Form Generator uses a more declarative approach with a single component, while Vueform offers a more flexible, composable API.
-
Customization: Vueform provides more granular control over form elements and styling.
-
Ecosystem: Vueform has a larger ecosystem with additional plugins and integrations.
-
Performance: Vue Form Generator may have a slight edge in performance for simpler forms due to its lighter-weight nature.
-
Learning Curve: Vue Form Generator is generally easier to get started with for basic forms, while Vueform offers more power at the cost of complexity.
Conclusion
Choose Vue Form Generator for simpler projects with basic form needs. Opt for Vueform when building complex, feature-rich forms that require extensive customization and scalability.
✅ Painless Vue forms
Pros of vee-validate
- Lightweight and flexible, with a smaller bundle size
- Supports asynchronous and custom validation rules
- Integrates well with Vue 3 and Composition API
Cons of vee-validate
- Requires more manual setup for complex forms
- Less out-of-the-box UI components compared to vue-form-generator
Code Comparison
vee-validate:
<template>
<Form @submit="onSubmit">
<Field name="email" :rules="emailRules" />
<ErrorMessage name="email" />
<button type="submit">Submit</button>
</Form>
</template>
vue-form-generator:
<template>
<vue-form-generator :schema="schema" :model="model" @validated="onValidated">
</vue-form-generator>
</template>
Summary
vee-validate offers a more lightweight and flexible approach to form validation in Vue applications, with better support for Vue 3 and custom validation rules. However, it requires more manual setup for complex forms compared to vue-form-generator.
vue-form-generator provides a more comprehensive solution with pre-built UI components and a schema-based approach, which can be advantageous for rapidly building complex forms. However, it may have a larger bundle size and less flexibility for custom validations.
The choice between these libraries depends on the specific needs of your project, such as form complexity, desired level of customization, and performance requirements.
🔥 Firebase bindings for Vue.js
Pros of vuefire
- Seamless integration with Firebase, providing real-time data synchronization
- Built-in support for Firestore, Realtime Database, and Authentication
- Lightweight and focused on Firebase-specific functionality
Cons of vuefire
- Limited to Firebase ecosystem, not suitable for other backend services
- Requires additional setup and configuration for Firebase projects
- Less flexibility in form generation compared to vue-form-generator
Code Comparison
vue-form-generator:
<template>
<vue-form-generator :schema="schema" :model="model" :options="formOptions">
</vue-form-generator>
</template>
vuefire:
<template>
<ul>
<li v-for="item in items" :key="item.id">{{ item.name }}</li>
</ul>
</template>
<script>
import { useCollection } from 'vuefire'
export default {
setup() {
const items = useCollection('items')
return { items }
}
}
</script>
Summary
vue-form-generator is a powerful form generation library for Vue.js, offering a wide range of form field types and customization options. It's ideal for complex form creation and management.
vuefire, on the other hand, is specifically designed for Firebase integration in Vue.js applications. It excels at real-time data synchronization and Firebase-specific features but lacks the form generation capabilities of vue-form-generator.
Choose vue-form-generator for advanced form creation and vuefire for Firebase-centric applications with real-time data requirements.
Build forms in React, without the tears 😭
Pros of Formik
- More flexible and customizable, allowing for complex form structures
- Better integration with React ecosystem and state management
- Extensive documentation and large community support
Cons of Formik
- Steeper learning curve for beginners
- Requires more boilerplate code for simple forms
- Limited built-in form field components
Code Comparison
Vue Form Generator:
<vue-form-generator :schema="schema" :model="model" :options="formOptions">
</vue-form-generator>
Formik:
<Formik
initialValues={initialValues}
validationSchema={validationSchema}
onSubmit={handleSubmit}
>
{({ errors, touched }) => (
<Form>
<Field name="email" />
{errors.email && touched.email ? <div>{errors.email}</div> : null}
<button type="submit">Submit</button>
</Form>
)}
</Formik>
Vue Form Generator provides a more declarative approach with a schema-based configuration, while Formik offers a more programmatic and flexible way to build forms in React applications. Vue Form Generator is generally easier to set up for simple forms, but Formik provides more control and customization options for complex scenarios.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
vue-form-generator

A schema-based form generator component for Vue.js.
Demo
Features
- reactive forms based on schemas
- multiple object editing
- 21 field types
- built-in validators
- core & full bundles (41kb and 50kb gzipped)
- Bootstrap friendly templates
- customizable styles
- can be extended easily with custom fields
- ...etc
Documentation
Online documentation on Gitbook
Dependencies
vue-form-generator uses fecha and lodash internally.
While built-in fields don't need external dependencies, optional fields may need other libraries. These dependencies fall into two camps: jQuery or Vanilla. You can find almost the same functionality in both flavors. In the end, it's your choice to depend on jQuery or not.
You can find details about dependencies in the official documentation under each specific component.
Installation
NPM
You can install it via NPM or yarn.
Latest version for Vue 2.x
$ npm install vue-form-generator
Legacy version for Vue 1.0.x
$ npm install vue-form-generator@0.6.1
Manual
Download zip package and unpack and add the vfg.css and vfg.js file to your project from dist folder.
https://github.com/vue-generators/vue-form-generator/archive/master.zip
Core vs Full version
VueFormGenerator come in two version : core
and full
.
Core is a more minimal version with only half the fields.
Full is core + other fields.
- Full bundle: 172 kB (gzipped: 50 kB)
- Core bundle: 146 kB (gzipped: 41 kB)
If you don't know what to choose, don't worry, the full is the default version. If you want the slim down version, here is the changes:
// the "full" way
<script>
import VueFormGenerator from "vue-form-generator";
import "vue-form-generator/dist/vfg.css"; // optional full css additions
</script>
// the "core" way
<script>
import VueFormGenerator from "vue-form-generator/dist/vfg-core.js";
import "vue-form-generator/dist/vfg-core.css"; // optional core css additions
</script>
Usage
<template>
<div class="panel-body">
<vue-form-generator :schema="schema" :model="model" :options="formOptions"></vue-form-generator>
</div>
</template>
<script>
import Vue from 'vue'
import VueFormGenerator from 'vue-form-generator'
import 'vue-form-generator/dist/vfg.css'
Vue.use(VueFormGenerator)
export default {
data () {
return {
model: {
id: 1,
name: 'John Doe',
password: 'J0hnD03!x4',
skills: ['Javascript', 'VueJS'],
email: 'john.doe@gmail.com',
status: true
},
schema: {
fields: [
{
type: 'input',
inputType: 'text',
label: 'ID (disabled text field)',
model: 'id',
readonly: true,
disabled: true
},
{
type: 'input',
inputType: 'text',
label: 'Name',
model: 'name',
placeholder: 'Your name',
featured: true,
required: true
},
{
type: 'input',
inputType: 'password',
label: 'Password',
model: 'password',
min: 6,
required: true,
hint: 'Minimum 6 characters',
validator: VueFormGenerator.validators.string
},
{
type: 'select',
label: 'Skills',
model: 'skills',
values: ['Javascript', 'VueJS', 'CSS3', 'HTML5']
},
{
type: 'input',
inputType: 'email',
label: 'E-mail',
model: 'email',
placeholder: 'User\'s e-mail address'
},
{
type: 'checkbox',
label: 'Status',
model: 'status',
default: true
}
]
},
formOptions: {
validateAfterLoad: true,
validateAfterChanged: true,
validateAsync: true
}
}
}
}
</script>
Usage in local components
import VueFormGenerator from "vue-form-generator";
//component javascript
export default {
components: {
"vue-form-generator": VueFormGenerator.component
}
};
Development
This command will start a webpack-dev-server
with content of dev
folder.
npm run dev
Build
This command will build a distributable version in the dist
directory.
npm run build
Test
npm test
or
npm run ci
More fields new
VueFormGenerator supports custom fields. If you decide to release your custom field into the wild, please open a new issue so we can add you to a list here! Please try to use this naming convention for your custom field : vfg-field-* Example :
vfg-field-myfield
vfg-field-calendar
vfg-field-awesome-dropdown
This way, it will be easier for everyone to find it. Thank you !
Public Custom Fields
- vue-tel-input - International Telephone Input Boilerplate with Vue (integrated with VueFormGenerator).
- vfg-field-sourcecode - A source code field for vue-form-generator
- vfg-field-array - A vue-form-generator field to handle arrays of items of any type.
- vfg-field-object - A vue-form-generator field to handle objects, with or without schemas.
- vfg-field-matrix - A matrix field for vue-form-generator.
Contribution
Please send pull requests improving the usage and fixing bugs, improving documentation and providing better examples, or providing some testing, because these things are important.
License
vue-form-generator is available under the MIT license.
Contact
Copyright (C) 2017 Icebob
Top Related Projects
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot