Skip to content

Comments

refactor(forms): restrict reactive logic to a readonly API#67161

Draft
leonsenft wants to merge 3 commits intoangular:mainfrom
leonsenft:sf-readonly-logic
Draft

refactor(forms): restrict reactive logic to a readonly API#67161
leonsenft wants to merge 3 commits intoangular:mainfrom
leonsenft:sf-readonly-logic

Conversation

@leonsenft
Copy link
Contributor

Reactive logic in forms is not intended to mutate state, but this was poorly communicated by the permissive and highly mutable field context provided to all logic functions. This change splits all of the state-related API into writable and readonly interfaces.

  • Top-level functions that produce a FieldTree (e.g. form()) expose writable signals (e.g. value: WritableSignal<T>) and mutating methods (e.g. markAsDirty()).

  • Reactive logic expose readonly signals (e.g. value: Signal<T>) and omit mutating methods.

Fix #65779.

* Remove unused `TValue` type parameter from `FormUiControl`
* Remove unused imports
* Remove unnecessary cast
@leonsenft
Copy link
Contributor Author

leonsenft commented Feb 20, 2026

Splitting the first cleanup commit out into its own PR while I iterate on this one: #67182.

Reactive logic in forms is not intended to mutate state, but this was
poorly communicated by the permissive and highly mutable field context
provided to all logic functions. This change splits all of the
state-related API into writable and readonly interfaces.

* Top-level functions that produce a `FieldTree` (e.g. `form()`) expose
  writable signals (e.g. `value: WritableSignal<T>`) and mutating
  methods (e.g. `markAsDirty()`).

* Reactive logic expose readonly signals (e.g. `value: Signal<T>`) and
  omit mutating methods.
Introduce `FormFieldBinding` to represent a binding between a field and
a UI control through a `FormField` directive. This interface is used to
restrict `SignalFormsConfig` and `formFieldBindings` to a readonly API.

Fix angular#65779.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: forms forms: signals target: minor This PR is targeted for the next minor release

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

feat(signal forms): make provideSignalFormsConfig / SchemaFn more robust against signal writes

1 participant