Skip to content

Latest commit

 

History

History
51 lines (45 loc) · 1.72 KB

FormBuilder.md

File metadata and controls

51 lines (45 loc) · 1.72 KB

Form Builder

Creates an AbstractControl from a user-specified configuration.

It is essentially syntactic sugar that shortens the new FormGroup(), new FormControl(), and new FormArray() boilerplate that can build up in larger forms.

How To Use

imoprt { FormBuilder } from "react-reactive-form";
...
const form = FormBuilder.group({
  name: FormBuilder.group({
     first: ['Jon', Validators.minLength(2)],
     last: 'Snow',
  }),
  email: '',
});

Members

static group(controlsConfig: {
    [key: string]: any;
}, extra: {
    [key: string]: any;
} | null = null): FormGroup

Construct a new FormGroup with the given map of configuration. Valid keys for the extra parameter map are same as AbstractControlOptions.

static control(
  formState: Object, 
  validator?: ValidatorFn | ValidatorFn[] | null, 
  asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null,
  updateOn: FormHooks): FormControl

Construct a new FormControl with the given formState,validator,asyncValidator and updateOn. formState can either be a standalone value for the form control or an object that contains both a value and a disabled status.

static array(controlsConfig: any[], extra?: AbstractControlOptions|null): FormArray

Construct a FormArray from the given controlsConfig array of configuration. Valid keys for the extra parameter map are same as AbstractControlOptions.



Note: This document is a derivative of "Form Builder Document" by Google, under CC BY.