Skip to content

Commit 6ea505f

Browse files
committed
docs: add signal forms to Overview of select ErrorStateMatcher
1 parent a27cae4 commit 6ea505f

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

‎src/material/select/select.md‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,19 @@ with your `<select>` or `<mat-select>`. By default, these error messages are sho
138138
either the user has interacted with (touched) the element or the parent form has been submitted. If
139139
you wish to override this behavior (e.g. to show the error as soon as the invalid control is dirty
140140
or when a parent form group is invalid), you can use the `errorStateMatcher` property of the
141-
`<mat-select>`. The property takes an instance of an `ErrorStateMatcher` object. An
142-
`ErrorStateMatcher` must implement a single method `isErrorState` which takes the `FormControl` for
143-
this `<mat-select>` as well as the parent form and returns a boolean indicating whether errors
144-
should be shown. (`true` indicating that they should be shown, and `false` indicating that they
145-
should not.)
141+
`<mat-select>`. The property takes an instance of an `ErrorStateMatcher` object.
142+
143+
For reactive forms, an `ErrorStateMatcher` must implement a single method `isErrorState` which takes
144+
the `FormControl` for this `<mat-select>` as well as the parent form and returns a boolean indicating
145+
whether errors should be shown. (`true` indicating that they should be shown, and `false` indicating
146+
that they should not.)
147+
148+
For signal forms, an `ErrorStateMatcher` must still implement the method `isErrorState` for backwards
149+
compatability with the reactive forms API, but it can be fullfilled with
150+
`isErrorState() {return false}`. Then the custom matcher can implement `isSignalErrorState`, which
151+
takes the `Field` for this `<mat-select>` as well as the parent form and returns a boolean indicating
152+
whether errors should be shown. (`true` indicating that they should be shown, and `false` indicating
153+
that they should not.)
146154

147155
<!-- example(select-error-state-matcher-signal-form) -->
148156

0 commit comments

Comments
 (0)