forms_skill

This skill helps you choose and use Angular forms best practices, including signals and reactive forms, to validate, manage state, and simplify form handling.

198

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill gentleman-programming/gentleman-skills --skill forms

  • SKILL.md2.7 KB

Overview

This skill helps you choose and implement Angular form patterns: Signal Forms (experimental) and Reactive Forms, plus guidance for nested structures and FormArray. It summarizes when to use each approach, key APIs, and practical tips for validation, type safety, and state handling. Use it when building or refactoring forms in Angular applications.

How this skill works

The skill inspects form requirements (signals compatibility, production readiness, complexity) and recommends Signal Forms for new signal-based apps or Reactive Forms for production stability. It explains core APIs: signal form() with FormField bindings and automatic two-way updates, and FormBuilder nonNullable.group() with formControlName, validators, and synchronous state for testing. It also covers nested FormGroup and FormArray patterns and how to read typed values.

When to use it

  • Start new projects that use Angular signals: Signal Forms (experimental) for concise, type-safe bindings.
  • Use Reactive Forms for production apps that need maturity, testability, and synchronous behaviour.
  • Choose template-driven forms only for very simple, small forms with minimal logic.
  • Use Signal Forms when you want automatic two-way binding and signal-based reactivity.
  • Use Reactive Forms when you require guaranteed stability, complex validation, or wide library support.

Best practices

  • For Reactive Forms always use fb.nonNullable.group() to preserve non-null types and avoid type casts.
  • Use getRawValue() on Reactive Forms to retrieve a typed snapshot of form values safely.
  • Keep validation declarative: use Validators with Reactive Forms or schema validators with Signal Forms for consistent error handling.
  • Encapsulate nested groups and arrays in small helper methods or components to keep components readable.
  • Prefer synchronous operations in Reactive Forms for easier unit testing; use async validators only when necessary.

Example use cases

  • Login form with email and password: Reactive Forms for production, Signal Forms for a signals-based app prototype.
  • Complex profile editor with nested address and dynamic phone numbers: Reactive Forms with FormArray and nested FormGroup.
  • New app using signals: build forms with form(), export FormField bindings directly into inputs for automatic two-way updates.
  • Migration plan: keep Reactive Forms in production modules and experiment with Signal Forms in feature branches before wider adoption.

FAQ

Signal Forms are experimental as of Angular v21+; they are great for new signal-first apps but prefer Reactive Forms for production stability.

How do I get typed values from a Reactive Form?

Use fb.nonNullable.group() to maintain types and call getRawValue() to retrieve a typed object of current values.

How do I handle dynamic lists of controls?

Use FormArray in Reactive Forms: create controls with fb.control(), expose a getter for the array, and push/pop controls. Encapsulate add/remove logic in methods.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
forms skill by gentleman-programming/gentleman-skills | VeilStrat