feat(forms): allow both patching and strict setting of values #10537
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For background, see the discussion here.
Short version:
We are splitting
updateValue()
into two functions:setValue(): this works much like updateValue() does now. The value passed must exactly match the structure of the form, and it will throw an error if it receives a superset or a subset of the form. This is what we'd recommend using in most cases since it will not fail silently.
patchValue(): this is a more forgiving function that will do its best to match controls based on the list it is passed. It will not throw for unrecognized control names, so supersets and subsets will both work. This is what you'd use if you want to include extra properties like created_by.
updateValue() itself is deprecated. Note that this is only happening for the updateValue() that existed in RC.4 (for individual form controls), as updateValue() for FormGroups and FormArrays was never released.
Closes #10057