* Patches the value of the `FormGroup`. It accepts an object with control * names as keys, and does its best to match the values to the correct controls * in the group. * * It accepts both super-sets and sub-sets of the group without throwing an error. * * @usageNotes * ### Patc
(
value: ɵFormGroupValue<TControl>,
options: {
onlySelf?: boolean;
emitEvent?: boolean;
} = {},
)
| 478 | * the {@link AbstractControl#updateValueAndValidity updateValueAndValidity} method. |
| 479 | */ |
| 480 | override patchValue( |
| 481 | value: ɵFormGroupValue<TControl>, |
| 482 | options: { |
| 483 | onlySelf?: boolean; |
| 484 | emitEvent?: boolean; |
| 485 | } = {}, |
| 486 | ): void { |
| 487 | // Even though the `value` argument type doesn't allow `null` and `undefined` values, the |
| 488 | // `patchValue` can be called recursively and inner data structures might have these values, so |
| 489 | // we just ignore such cases when a field containing FormGroup instance receives `null` or |
| 490 | // `undefined` as a value. |
| 491 | if (value == null /* both `null` and `undefined` */) return; |
| 492 | (Object.keys(value) as Array<keyof TControl>).forEach((name) => { |
| 493 | const existingControl = this._find(name as string); |
| 494 | if (existingControl) { |
| 495 | existingControl.patchValue( |
| 496 | /* Guaranteed to be present, due to the outer forEach. */ value[ |
| 497 | name as keyof ɵFormGroupValue<TControl> |
| 498 | ]!, |
| 499 | {onlySelf: true, emitEvent: options.emitEvent}, |
| 500 | ); |
| 501 | } |
| 502 | }); |
| 503 | this.updateValueAndValidity(options); |
| 504 | } |
| 505 | |
| 506 | /** |
| 507 | * Resets the `FormGroup`, marks all descendants `pristine` and `untouched` and sets |
nothing calls this directly
no test coverage detected