Skip to content

forms: Provide a submission value that excludes disabled/hidden fields #70732

Description

@xripcsu

Which @angular/* package(s) are relevant/related to the feature request?

forms

Description

Signal Forms currently expose form().value(), which represents the complete value of the underlying model, including fields that are disabled or hidden.

It would be useful to have a separate API that returns only values that are enabled and not hidden

For example:

const model = signal({
  name: 'John',
  email: 'john@example.com',
  role: 'admin',
});

const myForm = form(model, (schemaPath) => {
  disabled(schemaPath.role);
});

Currently we can get

{
  name: 'John',
  email: 'john@example.com',
  role: 'admin'
}

with myForm().value(); or model()

but we can't get this

{
  name: 'John',
  email: 'john@example.com',
}

this is possible to do in reactive forms with value/getRawValue() so I think that signal forms should also provide this possibility

Proposed solution

FieldState object could include signal with value without disabled/hidden fields

so to get

{
  name: 'John',
  email: 'john@example.com',
}

we could use something like myForm().submitValue();

Alternatives considered

Another possible approach would be to expose this through the existing submission API, for example:

submit(form, ({ value }) => {
  // value contains only fields that should be submitted
});

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: formsgemini-triagedLabel noting that an issue has been triaged by gemini

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions