Preface
Formation is a form framework for Angular 1.5+ designed for medium-to-large applications that require consistent, robust forms. It aims to reduce template size by moving business logic to controllers, which encourages code-reuse and improves consistency.
Feature Overview
- Controls are configured using Plain Old JavaScript Objects rather than directives. Configuration definitions can be shared across an application or abstracted into custom components. (See: Form & Control Configuration)
- Model values are managed by the form and passed to the form's submit handler, completely eliminating the need to bind model values to a scope. (See: Working With Model Values)
- A form's submit handler will only be called when it should be, eliminating the need for repititious checks for
form.$valid
. (See: Submitting) - Using
ngMessages
for validation has been greatly simplified; error messages are defined in code, reducing template bloat, eliminating the need to bind error messages to a scope, and making it easier to share common messages across an application. - Easily assign custom error messages on form controls at runtime (from your API, for example). (See: Errors)
- Configuring when to display validation errors can be done application-wide or for each form, and is as simple as providing a list of states (ex:
touched
,submitted
) to match against. (See:showErrorsOn
) - Reset all controls to a pristine, untouched state and optionally reset their model values to an initial state. (See:
reset
) - Using
ngDisabled
on a Formation form does what you would expect it to do; disables all controls in the form. - Accessibility: Formation uses ARIA attributes where applicable, and assigns matching
id
andfor
attributes to controls and labels, ensuring they are correctly associated with each other. Formation is alsongAria
-friendly.