npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

vue-dynamic-forms

v1.1.0

Published

a dynamic form component for Vue.js

Downloads

58

Readme

Dynamic forms

Table of Contents

create dynamic forms with vue based on a json configuration

Documetation

Form

Parameters

  • inputs Array A list of all the required form fields with initial values form more info see the params section
  • request Object A object containing an optional the configuration for the requests (optional)
    • request.headers Headers A Javascript Headers object containing custom headers (optional)
    • request.credentials String set credentials option in the request (optional) default value='omit'
    • request.url String The url which the form will be send to (optional) default value = ''(self)
    • request.method String The method of the request (optional) default value = 'post'
  • config Object the configuration of the whole form

data

groups all form values in a formData object

Returns FormData data - a FormData object containing all form values

reset

Resets all values in the form + clears the errors

submit

Submit the form with the current values

Returns Promise promise based on the succes or failure of a request done with the fetch API

onFail

Sets the Errors of the form

Parameters

  • errors Array An array containing error objects

Input

an input object in the inputs array

Parameters

  • input Object an input configuration

    • input.type String (Required) - The type of input supported input types: text,email,password,hidden,tel,date,number,select,textarea
    • input.name String (Required) - The name of the input field
    • input.value (Optional) - The value of the input field
    • input.label String (Optional) - The label of the input field
    • input.class String (Optional) - The Css class(es) of the input field

    Input specific parameters

    • input.min minimum value of the input field(date,number)
    • input.max maximum value of the input field(date,number)
    • input.step Number increments of the value on increase & decrease(number)
    • options Array all the options in a selectbox

Errors

has

Check if an error exists

Parameters

  • field String the name of the field you are looking for

any

Check if there are any Errors

Returns Boolean boolean

get

get an Error for a particular field

Parameters

  • field String the name of the field you are looking for

Returns any if exists returns the error else returns false

set

Sets the error Object

Parameters

  • Errors errors
  • err

clear

Clear all the erros

Example

add the component to the components section of your Vue component

demo.vue

<template>
<div>
	<!-- 
		custom html element
		custom atribute formdata is required
	 -->
	<dynamic-form :formdata="formdata"></dynamic-form>
</div>
</template>

<script>
//import the library
import dynamicForm from 'vue-dynamic-forms'

import { createDemo } from './config'

export default {

	name: 'demo',
	components:{
		//add the dynamicForm to the components section
		dynamicForm
	}
	data () {
		return {
			//get the configuration and initialize it
			formdata:createDemo()
		};
	}
};
</script>

<style lang="css" scoped>
</style>

Configuration

configuration in the config.js file

export fuction createDemo(){

	return {
		//request options 	
		request:{
			//post url
			url:'/register',
			//method
			method:'post',
			//adding the CSRF Token for laravel applications
			headers:new Headers({
				'X-CSRF-TOKEN':window.Laraval.csrfToken
			}),
			//include credentials
			credentials:'include'
		},
		//title
		title:'Demo Form'
		//text of the submit button
		submitText:'Register',
		//inputs
		inputs:[
			{
				type:'text',
				label:'Firtsname',
				name:'firstname',
				class:'form-control',
				value:''
			},
			{
				type:'text',
				label:'Lastname',
				name:'lastname',
				class:'form-control',
				value:''
			},
			{
				type:'email',
				label:'Email',
				name:'email',
				class:'form-control',
				value:''
			},
			{
				type:'password',
				label:'Password',
				name:'password',
				class:'form-control',
				value:''
			},
			{
				type:'password',
				label:'Confirm password',
				name:'password_confirmation',
				class:'form-control',
				value:''
			},
			{
				type:'date',
				label:'Date of birth',
				name:'dateofbirth',
				class:'form-control',
				value:''
			},
			{
				type:'tel',
				label:'Telephone',
				name:'phone',
				class:'form-control',
				value:''
			},
			{
				type:'select',
				label:'Gender',
				name:'gender',
				class:'form-control',
				options:['male','female'],
				value:""
			},

		]
	}
}