top of page

Angular dynamic large-scale forms

Angular library to generate forms dynamically by having the ability to customize, manipulate and scale it easy.

Formify model generate and manipulate a form

Simply can be generated by passing config FormifyState parameter.

public formify = new FormifyModel({
  controls: [ // controls config
    new FieldModel(config),
    new GroupModel(config),
    new ArrayModel(config),
  submit: config, // submit button config,
  options: config, // options config

Accessibility and manipulation by calling functions and instance variables.

this.formify.field('color').update({hidden: false });'contact')
this.formify.formGroup.get('color').valueChanges.subscribe(color => { // handle color change
this.formify.addControl(new FieldModel());

Control Models

Make it possible to configure and generate from controls as you need. Offers accessibility and manipulation.

Generate Control FieldModel instance

new FieldModel({
  controlName: 'email',
  label: 'Email address',
  placeholder: 'email',
  icon: 'email',
  autoComplete: 'off',
  validators: [
    new ValidatorModel({
        validator: Validators.required, errorCode: 'required',
        description: 'identity is required'
    new ValidatorModel({
        validator: Validators.pattern(EmailRegex),
        errorCode: 'pattern',
        description: 'Email address is incorrect'
    new ValidatorModel({
        validator: null, errorCode: 'exist',
        description: 'This email exist in database'

Control GroupModel and ArrayModel can be generated in same way just passing controlName and Controls

const ContactGroupModel = new GroupModel({
  controlName: 'contact',
  label: 'Contact',
  controls: [
    new PhoneFieldControl(overwrite?), // extends by FieldModel
    new EmailFieldControl(overwrite?), // extends by FieldModel
    new FieldModel(config)

new ArrayModel({
  controlName: 'addresses', label: 'Address:',
  controls: [ 

Control Components

Supporting ControlValueAccessor for using nested forms. Getting control model and generating nested formGroup. Offering functions for accessing datasource and validation errors.

Reusable Components

Input, Textarea, Select, Radio, Toggle and Checkbox that are extends from FieldControlComponent. So easy you can create another reusable component by extending one of Control Components

Creating Custom Components

export class CustomFieldComponent extends FieldControlComponent implements OnInit , OnChanges{
  constructor(protected formBuilder: FormBuilder) {   
     super(formBuilder); }
  ngOnChanges(changes: SimpleChanges):void {
  ngOnInit(): void {super.ngOnInit(); }

export class CustomGroupComponent extends GroupControlComponent implements OnInit {
  constructor() { super(); }
  ngOnInit(): void {

Creating Custom Controls

export class ColorFieldControl extends FieldModel {
  constructor(overwrite: FieldState  = {}) {
    const  field: FieldModel =  new FieldModel({
      controlName: 'color',
      label: 'Color',
      defaultValue: 'primary',
      options: [
        {text: 'Primary', value: 'primary'},
        {text: 'Accent', value: 'accent'},
        {text: 'Warn', value: 'warn'}]
    super(Object.assign(field , overwrite));

export class ContactGroupControl extends GroupModel {
  constructor(overwrite: GroupState  = {}) {
    const  group: GroupModel = new GroupModel({
      controlName: 'contact',
      label: 'Contact:',
      controls: [ config controls ]
    super(Object.assign(group , overwrite));

Displaying in Template

Support two way of to displaying the form in template. 1. Using Formify component and passing FormifyModel.

<formify [formify]="formify" (submit)="onSubmit()"></formify>

2. Custom displaying by including reusable/custom components and passing ControlModel manually.

<form [formGroup]="formify.formGroup" (ngSubmit)="onSubmit()">
   <formify-input formControlName="firstName"   
   <formify-select formControlName="languages" 
   <formify-textarea formControlName="biography" 
   <formify-addresses [arrayModel]="formify.array('address')">  
   <formify-contact [groupModel]="'contact')"> 
   <formify-submit [submit]="formify.submit"></formify-submit>

If you wanna look in details how it is build check it out or take a look to live examples

Source: Medium

The Tech Platform


Recent Posts

See All


bottom of page