Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ng-formly

formly-js134MITdeprecated2.0.0TypeScript support: included

This package is deprecated, use '@ngx-formly/core' and '@ngx-formly/bootstrap' instead

ng-formly is an Angular 2 module which has a Components to help customize and render JavaScript/JSON configured forms. The formly-form Component and the FormlyConfig service are very powerful and bring unmatched maintainability to your application's forms

angular, forms, ng-formly, formly, angular 2, angular 2 forms, json forms, form library

readme

angular-formly logo

ng-formly

Angular Style Guide All Contributors Stories in Ready

Status: Build Status npm version devDependencies Status Package Quality Known Vulnerabilities codecov.io

Links: Gitter PRs Welcome

angular2-formly is an Angular 2 module which has a Components to help customize and render JavaScript/JSON configured forms. The formly-form Component and the FormlyConfig service are very powerful and bring unmatched maintainability to your application's forms.

Quick Start

1. Install ng-formly

  npm install ng-formly --save

2. Import the FormlyModule:

import {NgModule} from '@angular/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {BrowserModule} from '@angular/platform-browser';
import {FormlyModule, FormlyBootstrapModule} from 'ng-formly';
import {AppComponent} from './app';

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    ReactiveFormsModule,
    FormlyModule.forRoot(),
    FormlyBootstrapModule,
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule {
}

3. Define the form config in your component:

import {Component} from '@angular/core';
import {Validators, FormGroup} from '@angular/forms';
import {FormlyFieldConfig} from 'ng-formly';

@Component({
  selector: 'app',
  template: `
    <form class="formly" role="form" novalidate [formGroup]="form" (ngSubmit)="submit(user)">
        <formly-form [model]="user" [fields]="userFields">
            <button type="submit" class="btn btn-default">Button</button>
        </formly-form>
    </form>
  `,
})
export class HelloApp {
  form: FormGroup = new FormGroup({});
  userFields: Array<FormlyFieldConfig> = [{
    className: 'row',
    fieldGroup: [{
        className: 'col-xs-6',
        key: 'email',
        type: 'input',
        templateOptions: {
            type: 'email',
            label: 'Email address',
            placeholder: 'Enter email'
        },
        validators: {
          validation: Validators.compose([Validators.required])
        }
    }, {
        className: 'col-xs-6',
        key: 'password',
        type: 'input',
        templateOptions: {
            type: 'password',
            label: 'Password',
            placeholder: 'Password',
            pattern: ''
        },
        validators: {
          validation: Validators.compose([Validators.required])
        }
    }]
  }];

  user = {
    email: 'email@gmail.com',
    checked: false
  };

  submit(user) {
    console.log(user);
  }
}

From there, it's just JavaScript. Allowing for DRY, maintainable, reusable forms.

Roadmap

See the issues labeled enhancement

Supported templates

Thanks

A special thanks to Kent C. Dodds for giving me opportunity to work on this. This library is maintained (with love) by me, Mohammed Zama Khan. Thanks to all contributors! If you're trying to find angular-formly, go here

Contributors

Thanks goes to these wonderful people (emoji key):


Zama Khan Mohammed

📖 💻 👀 💁 🚇 🔧

Abdellatif Ait boudad

💻 📖 ⚠️ 👀 💁

divyakumarjain

💻 📖 🔌 👀 💁

Pouja

💻 👀

Caleb Kniffen

🐛

Riron

🐛

Thiago Lacerda

🐛

danielcrisp

🐛 💻

Tony Franzese

🐛 💻

Jackie Gleason

🐛 💻

ampsarfraz

🐛

Krustie101

🐛 💻

ultimafirez

🐛

This project follows the all-contributors specification. Contributions of any kind welcome!

changelog

Change Log

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

2.0.0 (2017-11-01)

Features

  • added support for Angular version 5. (d650634)

1.0.0 (2017-11-01)

Change Log

1.0.0-rc.10 (2017-06-20)

Full Changelog

Fixed bugs:

  • multicheckbox validation issue #448

Closed issues:

  • what is the latest version? #446
  • Dependency between fields of different groups #445
  • radio buttons is exclusive in different Fields #444
  • Type Configuration Validation #435

Merged pull requests:

  • fix(FormlyFieldMultiCheckbox): supply validators to control #450 (franzeal)
  • fix(validation) allow null/empty and equal values in min/max validation #449 (Tom-V)
  • chore(CHANGELOG): Update changelog #447 (aitboudad)

1.0.0-rc.9 (2017-06-02)

Full Changelog

Closed issues:

  • Problem with updating the data #437

Merged pull requests:

  • docs(import): use ng-formly instead of ng-formly/core #443 (aitboudad)

1.0.0-rc.8 (2017-06-01)

Full Changelog

Closed issues:

  • Please update CHANGELOG.md #438

Merged pull requests:

  • fix(FormlyForm): allow className even if fieldGroup is set #442 (aitboudad)
  • feat(options form): allow using custom resetModel + updateInitialValue #441 (aitboudad)
  • chore(CHANGELOG): Update changelog #440 (aitboudad)
  • feat(bootstrap): split bootstrap from the core #439 (aitboudad)
  • chore(readme): fix bootstrap template repo link #369 (blowsie)

1.0.0-rc.7 (2017-05-29)

Full Changelog

Closed issues:

  • hideExpression not working correctly when using formState #430
  • the validation of repeatSection custom type doesnt not affect the main Form valid status #426
  • Custom type "extends" Input type but not "extends" Input features #415
  • Required validation should be ignored when hideExpression applies (true) #406
  • Repeat section validation does not impact main form. #384

Merged pull requests:

1.0.0-rc.6 (2017-05-20)

Full Changelog

Closed issues:

  • On demo "import { clone } from '../../../../src/core/utils';" doesn't exist. #421
  • Support for Angular 4 and Roadmap for the future developments #419
  • Browse File Button #418
  • How to handle dynamic options in 'select' type #414

Merged pull requests:

1.0.0-rc.5 (2017-05-16)

Full Changelog

Closed issues:

  • How to determine if there is error in the form? #413
  • Forms do not render, console says "TypeError: Cannot read property 'templateOptions' of undefined" #411

Merged pull requests:

1.0.0-rc.4 (2017-05-01)

Full Changelog

Closed issues:

  • Formly duplicates provided classNames #404
  • Focus on input Element #403
  • Focus on a particular element in ng2-formly #402
  • Multiple Checkbox example #400
  • Angular 4 compatibility #399
  • Watchers are not supported. #398
  • lifecycle.onChanges event is not working #397
  • ngonchange is not working in ng2-formly #395
  • Share values of inputs between multiple ones #394
  • Sample for loading form layout from service #362

Merged pull requests:

  • fix(#406): ensure hideExpression to return boolean value. #410 (aitboudad)
  • Revert "feat(FormlyField): allow setting className for fieldGroup #405 (aitboudad)

v1.0.0-rc.2 (2017-03-17)

Full Changelog

Closed issues:

  • Lifecycle onChanges not working #390
  • Error with angular@4.0.0-beta.7 #382
  • tslint failed on "no-access-missing-member" #379
  • ngc "--project" "tsconfig.build.json" failing #376
  • Export ConfigOption #375
  • Top-level repo needs to export everything from src/index.ts #372

Merged pull requests:

  • chore(upgrade) update version to rc-2. #393 (aitboudad)
  • feat(FormlyField): allow setting className for field which contains fieldGroup #392 (aitboudad)
  • feat(FormlyConfig): introduce addConfig method #388 (aitboudad)
  • fix(field): ignore assigning defaultValue only when it's undefined. #387 (aitboudad)
  • fix(validation): allow set validation for field group. #386 (aitboudad)
  • feat(deps): allow angular v4. #385 (aitboudad)
  • feat(FormlyField): use ng-container instead of deprecated template. #383 (aitboudad)
  • feat(rxjs): better usage of rxjs operators. #381 (aitboudad)
  • feat(module): add forChild for child module. #380 (aitboudad)
  • feat(config): export ConfigOption. #378 (aitboudad)
  • fix(npm): fixed #376 #377 (aitboudad)

v1.0.0-rc.1 (2017-02-16)

Full Changelog

Closed issues:

  • Advanced Layout : Display a field value in a html section set inside the FormlyFieldConfig Array #374
  • Problem adding a new property inside field #365
  • Disable submit button #359
  • Can not get formly working as component using webpack admin template #358
  • Disable submit button in ng2-formly #357
  • How use only formly-field without fomrly-form. #356

Merged pull requests:

  • fix(#372): export everything from ./src/index.ts #373 (beeman)
  • feat(FormlyAttributes): change field focus when element is blurred. #371 (aitboudad)
  • fix(FormlyField): check field before removing the emitter. #368 (aitboudad)
  • feat(webpack): Upgrade to webpack v2 #364 (aitboudad)
  • fix(field): fixed assign default value for nested form. #363 (aitboudad)
  • feat(FormlyField): destroy all componentRefs + _subscriptions. #361 (aitboudad)
  • feat(FormlyAttributes): render field id and name. #360 (aitboudad)

v1.0.0-rc.0 (2016-12-18)

Full Changelog

Implemented enhancements:

  • Asynchronous resolution of validation messages #334
  • Arrays in Property Keys #333
  • [field] allow providing custom formControl through field config #325
  • [BC][wrapper] wrappers are rendered in the reverse order compared to angular-formly #322
  • Field.validation.messages #307

Closed issues:

  • resetModel broken with FormArrays #350
  • Repeat Section [Validation not being applied to investmentDate] #349
  • model / fields circular references #346
  • repeatSection / fieldArray does not emit form valueChanges #344
  • Validators Expression not triggered for Checkboxes #337
  • ng2-select with formly #332
  • [buildForm] should be called only once #330
  • Using callback function to reset field model when hidden #328
  • Parameter 'x' implicitly has an 'any' type after adding ng2-formly modules #323
  • [BC][field-config] angular-formly use wrapper rather than wrappers #321
  • [Validation] Hidden fields should be marked as valid #318
  • FieldExpression does not applied to field with FieldGroup #317
  • Expression properties error #270

Merged pull requests:

v2.0.0-beta.14 (2016-12-07)

Full Changelog

Implemented enhancements:

  • Custom Validators with expression + message #269
  • valueProp and labelProp in type select #258
  • Upgrade to 2.2.0 #257
  • FIELD TRANSFORM #246
  • Model binding to a formly-field in FormlyForm will not work with a nested property #230
  • Grouped Select #202
  • Add unit tests #182
  • Expression properties should be able to take function #148

Closed issues:

  • How can i implement repeating section using ng2-formly #312
  • Not getting Typescript and Webpack config when using github and npm #308
  • repeated section produces errors #303
  • Allow for periods in key of radio #301
  • RepeatSection cannot be reset properly. #288
  • Field with nested property loses wrappers #282
  • Change needs to be added to FormlyTemplateOptions #279
  • OnChange isn't working when set async (Like on an RXJS subject) #277
  • Request for an example for options for select field from a remote API through a service #271
  • [Field type] get model value using model\[key\] instead of model #265
  • Formly in Tabs #263
  • Need CONTRIBUTING.md file for the project #262
  • event async loading in a field select #255
  • Run time error while running to the device #239

Merged pull requests:

v2.0.0-beta.13 (2016-11-14)

Full Changelog

Merged pull requests:

v2.0.0-beta.12 (2016-11-12)

Full Changelog

Implemented enhancements:

  • addonLeft and addonRight #223
  • Layout broken with Bootstrap v4 flexbox support enabled #215
  • formState implementation #203
  • defaultOption for a type #200
  • setType should also be able to take an array #199
  • add support for Form Options #172
  • Adding more templateOptions #171
  • Support for Async Validation #165
  • Handling onKeypress, onEnter, onLeave, onClick, onFocus, onBlur, onChange etc. #147
  • Support templateManipulators #25

Closed issues:

  • Running npm run demo fails on windows. #233
  • Formly-form controls are not rebound if model is changed programmatically #229
  • Extra formly tags removal #225
  • FormlyWrapperHorizontalLabel #220
  • Form Generator #135
  • [Doc][Field Type] create custom controls #115

Merged pull requests:

v2.0.0-beta.11 (2016-11-01)

Full Changelog

Implemented enhancements:

  • field and fieldGroup wrapper #204

Closed issues:

  • Radio buttons don't have names, so you can't use multiple groups #210
  • Code Coverage report not showing any data #190

Merged pull requests:

v2.0.0-beta.10 (2016-10-29)

Full Changelog

Closed issues:

  • Form does not initialize inner properties #192

Merged pull requests:

v2.0.0-beta.9 (2016-10-27)

Full Changelog

Implemented enhancements:

  • Merging validators and validation as well as asyncValidators and asyncValidation #170
  • Add Unit tests #79

Closed issues:

  • Add an event on form controls ready #183

Merged pull requests:

v2.0.0-beta.8 (2016-10-26)

Full Changelog

Implemented enhancements:

  • Simpler Validation #163
  • defaultValue property for a field #154
  • Template Options should be able to accept additional Custom options #152
  • Lifecycle Hooks in Formly #150
  • Should be able to define the types for the wrappers #146
  • Dynamic Validation Messages #136
  • Nested Property Keys #121

Closed issues:

  • Fetch form metadata from server #155
  • Placeholders are not optional (display 'undefined') #140
  • Website for ng2-formly #133
  • update ngModule way of using ng2-formly in README.md #114

Merged pull requests:

2.0.0-beta.7 (2016-10-05)

Full Changelog

Implemented enhancements:

  • Group Validation #43
  • Support wrappers #26

Closed issues:

  • [ts] Cannot find module 'ng2-formly' #125
  • FormlyModule imports BrowserModule #123

Merged pull requests:

  • feat(formly-field) support extending types (with docs) #129 (mohammedzamakhan)
  • style(tslint): [quotemark] enforces single quotes #128 (aitboudad)
  • feat(formly-field): support wrappers #127 (aitboudad)
  • feat(umd): use webpack for umd-build. #126 (aitboudad)
  • fix(FormlyModule): use CommonModule instead of BrowserModule. #124 (aitboudad)
  • feat(FormlyModule): improve registering types, validators and validationMessage. #122 (aitboudad)
  • feat(build): Use ngc for AOT compilation & distribute ES modules + UMD bundle. #120 (aitboudad)
  • feat(modelOptions) Better way of handling debounce #119 (mohammedzamakhan)
  • feat(FormlyConfig): throw error when a type/validator doesn't exist. #118 (aitboudad)
  • feat(modelOptions) Basic Implementation of modelOptions with debounce… #117 (mohammedzamakhan)
  • refactor(FormlyField): remove FormlyCommon class. #116 (aitboudad)
  • docs(validation) Group Validation added fixes #43 #113 (mohammedzamakhan)
  • fix(changedetection): remove the temporary fix setTimeout. #112 (aitboudad)

2.0.0-beta.6 (2016-09-30)

Full Changelog

Implemented enhancements:

  • Support @angular/form 2.0.0-rc.6 #92
  • SingleFocusDispatcher not exported via index.ts #81
  • Add ng2Module support #80
  • Support Angular Universal #53
  • Support for Validation to be An Array of strings #41
  • 'focus' can only be true for one field #12

Fixed bugs:

  • css class form-control missing in most templates #82
  • Two Way binding for Radio button does not work #54
  • Demo throws error on Chrome (only on MAC) a #47

Closed issues:

  • Chrome Autofill Form throws error #108
  • No value accessor for form control with name: 'password' [In Demo] #102
  • Can we add aitboudad o the angular 2 formly core team? #100
  • Validation occurs before the user interacts with the form fields #97
  • NPM install not working #95
  • Invalid provider - only instances of Provider and Type are allowed, got: undefined #90
  • Can't bind to 'ngFormModel' #89
  • Repository for material templates #88
  • FormlyForm directive is error. #83
  • Several templates not checking for disabled attribute #75
  • Feature requests: add styling support for field-groups and make fields optional #74
  • Use @angular/formly instead of deprecated forms api breaks radio button #72
  • Update ng2-formly to use @angular/formly instead of deprecated forms api #70
  • ng2-formly.min.js:1 Uncaught ReferenceError: System is not defined #68
  • select options not showing #67
  • EXCEPTION: No Directive annotation found on FormlyForm #66
  • Aurelia-formly #63
  • Update to RC3 - dynamic form #62
  • Upgrade to RC2 #59

Merged pull requests:

2.0.0-beta.5 (2016-06-01)

Full Changelog

Fixed bugs:

  • Version 2.0.0-beta.3 typings error at installation #48
  • Two way Data Binding #45

Closed issues:

  • extend and multiple inheritance #56
  • More Repo to separate Core with Templates #55
  • Can we add divyakumarjain to angular2 formly core team member? #51

Merged pull requests:

2.0.0-beta.4 (2016-05-28)

Full Changelog

Merged pull requests:

  • Close #48 - beta.3 release issues #49 (couzic)

2.0.0-beta.3 (2016-05-26)

Full Changelog

Closed issues:

  • Typescript not compiling since 2.0.0-beta.1 #42
  • Uncaught ReferenceError: System is not defined #39

Merged pull requests:

  • Fix build - close #39 and #42 #46 (couzic)
  • feat(formly-form) remove unnessary event system to send data to forml… #44 (mohammedzamakhan)

2.0.0-beta.2 (2016-05-18)

Full Changelog

Implemented enhancements:

  • Not working expressionProperties #24
  • Separate Formly and Templates #15
  • templateOptions should be defined #13

Fixed bugs:

  • error TS2307: Cannot find module './control.service'. #32

Closed issues:

  • Update to Angular 2.RC1 #35
  • not bundle with webpack (lost control.service.d.ts) #18

Merged pull requests:

2.0.0-beta.1 (2016-05-14)

Full Changelog

Implemented enhancements:

  • Hide expression should be able to receive Expressions #14
  • Supporting Multi Checkbox #9

Closed issues:

  • npm script flow.compile:system not working on windows #29
  • Differentiator with Ng2 Forms #22
  • Efforts towards a web components/vanilla js formly core library #21
  • support for typeahead #19

Merged pull requests:

2.0.0-alpha.5 (2016-04-13)

Full Changelog

Implemented enhancements:

  • Bundle into one JS file for npm installs #7

Merged pull requests:

2.0.0-alpha.1 (2016-04-12)

Full Changelog

Merged pull requests:

2.0.0-alpha.0 (2016-04-08)

Closed issues:

  • Angular is Beta, so Formly development makes sense now #2
  • would like to help in angular2 migration #1

Merged pull requests:

* This Change Log was automatically generated by github_changelog_generator