Form Group

A form control group with multiple controls is similar to a custom control. To add multiple inputs to a form group it is required to add a control factory to the component. See the following example for more information.

Example

Step 1 - Create component

@Control({
  type: 'date-range',
})
@Component({
  selector: 'date-range-input',
  templateUrl: './date-range-input.component.html',
  styleUrls: ['./date-range-input.component.scss'],
})
export class DateRangeInputComponent {
  
  @ControlFactory()
  public static controlFactory(question: Question) {
    return new FormGroup({
      from: new FormControl(),
      until: new FormControl(),
    });
  }

  constructor(@Inject(FORM_CONTROL) public control: FormGroup) {}
}

Step 2 - Registration

The custom control component must be registered in the FastFormsModule. See the following example.

Root Module

Child Module

Last updated