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 🙏

© 2024 – Pkg Stats / Ryan Hefner

nz-form-builder

v1.0.0

Published

This is an Angular plugin that generates form dynamically using the JSON.

Downloads

16

Readme

Angular Dynamic Form Builder

This is an Angular plugin that generates form dynamically using the JSON.

Working Demo : https://stackblitz.com/edit/nz-form-builder

Note :

This Library has 2 Journeys (Create and Update) .

If the journey is CREATE , then an empty form is initialized according to the JSON.

If the journey is UPDATE , then pass dataToUpdate in the format defined below , so that form will initialize and patch the edit values.

Features.

  • Dynamic form building by providing JSON
  • Configuration for all input types and styles allowed
  • Your custom validation patterns and messages
  • Custom form generation with custom labels

Install

npm install nz-form-builder --save

Setup

Step1 : Import FormBuilderModule from the package nz-form-builder in app.module.ts file.

import { FormBuilderModule } from  'nz-form-builder'

Step2 : Add the FormBuilderModule in the NgModule Imports array.

imports: [FormBuilderModule]

Step3 : Add the following tags in the app.component.ts file.

<nz-form-builder  [fieldConfig]="fieldConfig" 
                  [formConfig]="formConfig"
                  (formValues)="onSubmit($event)" 
                  [journey]="journey"
                  [dataToUpdate]="dataToUpdate">
</nz-form-builder>

Pass fieldConfig, formConfig JSON to the library Create a method onSubmit() on the event formValues Pass Journey to the library pass dataToUpdate in update journey

The following is the JSON Basic configuration

 formConfig = {
         submitBtnName:'Submit',
         clearBtnRequired:true,
         clearBtnText:'Reset',
         formBackgroundColor:'#e0e0e0',
         headerText:'Dynamic Forms',
         headerTextAlign:'center',
         sectionClass:'col-sm-6 col-md-3',
		 containerClass:'container-fluid'
     }

 fieldConfig = [
    {
	     name:'firstname',
	     label:'First Name',
	     placeholder:'Enter First Name',
	     required:false,
	     requiredMsg:'Please enter first name',
	     pattern:'[a-zA-Z0-9]+',
	     patternMsg:'Select Valid Name',
	     type:'text',
	     disabled:false
     },
     {
	     name:'lastname',
	     placeholder:'Enter Last Name',
	     label:'Last Name',
	     required:true,
	     requiredMsg:'Please enter last name',
	     pattern:'',
	     patternMsg:'',
	     type:'text',
	     disabled:false,
	  },
	  {
		  name:'class',
		  placeholder:'Select class',
		  label:'Class',
		  required:true,
		  requiredMsg:'Please select class',
		  type:'dropdown',
		  options: ['8','9','10'],
		  disabled:  false
	  },
	  {
		  name:'dateofbirth',
		  label:'Date of Birth',
		  placeholder:'dd/mm/yyyy',
		  required:true,
		  requiredMsg:'Select Date of birth',
		  type:'date',
		  disabled:false
	   },
	   {
		   name:'gender',
		   label:'Gender',
		   required:true,
		   requiredMsg:'Please select Gender',
		   type:'radio',
		   options: ['male','female','others'],
		   disabled:  false
	   },
	   {
		   name:  'state',
		   label:  'State',
		   required:  true,
		   requiredMsg:  'Please select State',
		   type:  'checkbox',
		   options: [
			 {key:'AP', value:'ap',isChecked:false },
		     {key:'Karnataka', value:'karnataka',isChecked:false },
			 {key:'Tamil nadu', value:'tamilnadu',isChecked:false },
		 	 {key:'Kerala', value:'kerala',isChecked:false },
		 	 ],
		   disabled:  false,
		 },
		 {
				name:'address',
				label:'Address',
				placeholder:'Enter Address',
				required:  true,
				requiredMsg:'Enter Address',
				pattern:'',
				patternMsg:'',
				type:'textarea',
				disabled:false,
				rows:3
		 },
		 {
			 name:'file',
			 label:'File',
			 placeholder:'Select file',
			 required:true,
			 requiredMsg:'Please select a file',
			 type:'file',
			 disabled:false
		 }
	]

Journey = "create" or "update"

 dataToUpdate = dataToUpdate = {
                  "firstname":  "nizam",
                  "lastname":  "shaik",
                  "class":  "8",
                  "age":  "24",
                  "dateofbirth":  "1990-01-05",
                  "gender":  "male",
                  "state": [
                     {
                       "key":  "Nellore",
                       "value":  "nellore",
                       "isChecked":  true
                     },
                     {
                        "key":  "Kadapa",
                        "value":  "kadapa",
                        "isChecked":  true
                      }
                   ],
                  "address":  "buchi reddy palem",
           "file": {
             "0": {}
                }
             }

Credits

Author && Developer : Nizamuddin shaik

License

Mit License: http://www.opensource.org/licenses/mit-license.php