Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
powmedia committed Sep 8, 2011
1 parent 59077d0 commit 088e9f9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,30 @@ Optionally, you can include the extra editors, for example those that require jQ
Usage
=====

![Example form](http://i56.tinypic.com/a3zfyt.png)

You can create something like the form above with the following steps:

Define a 'schema' attribute on your Backbone models. The schema keys should match the attributes that get set on the model. Note that `type` defaults to `Text`.

var User = Backbone.Model.extend({
schema: {
id: { type: 'Number' },
name: {},
start: { type: 'DateTime' },
contact: { type: 'Object', subSchema: {
name: {},
phone: {}
}}
address: { type: 'NestedModel', model: Address },
email: { title: 'Email address' },
password: { type: 'Password' }
notes: { type: 'List' }
}
});

Create the form in your Views:

var formView = Backbone.View.extend({
render: function() {
var form = new Backbone.Form({
model: this.model
model: users.get(userId)
}).render();

$(this.el).append(form.el);
Expand Down Expand Up @@ -306,6 +312,7 @@ Known issues
============

- List editor with listType NestedModel doesn't run validation
- There may be CSS issues across browsers. You can customise your CSS by editing the backbone-forms.css file.

Contributors
============
Expand Down

0 comments on commit 088e9f9

Please sign in to comment.