Ember Form Object
Form object pattern in Ember apps (similar to ActiveModel Form Objects in Ruby on Rails)
Features
- Declarative validations (depends on ember-validations under the hood)
- Handles client & server side validation errors
- Properties proxied to / synced from model
- Virtual, async & readonly properties
- Well defined form save (submit) process with appropriate hooks
- Manage form "dirty", "loaded", "submitting" and "valid" state
- Prevent form loss with confirmation when leaving dirty form
- Add/remove properties in runtime (useful for dynamic forms)
- Detect model property conflicts while form is being edited (in "dirty" state)
Disclaimer
This project is currently in alpha phase. Public API of the library is still under active development.
Installation
ember install ember-form-object
Example usage
Form object for todo model
// app/forms/todo.js ;; ;
Route with form route mixin (which instantiates todo form object)
;; Route;
Non-model form object usage (login form)
;; ;
Development
TODOs (by priority)
- Add "isValid" state to each property
- Move server validation error logic to base form object
- Example page & docs
- Better test coverage
- Remove form-loss feature from route mixin and just add it as an example
- Add blueprints for ember-cli
Setup development environment
git clone
this repositorynpm install
bower install
Running dummy app
ember server
- Visit your app at http://localhost:4200.
Running Tests
npm test
(Runsember try:testall
to test your addon against multiple Ember versions)ember test
ember test --server
Authors
Want to help?
Contributors welcome.
Legal
Infinum LTD © 2016