Ember forms is a library for Ember.js to assist in the creation of forms, binding them to objects and extracting their data.
Just declare your form as a view extending EF.Form:
App.PostForm = EF.Form.extend({
content: person,
gender: Ember.A([{id: 'm', name: 'Male'}, {id: 'f', name: 'Female'}]),
template: Ember.Handlebars.compile(
'{{field name label="Post title"}}' +
'{{field interests as="textarea"}}' +
'{{field birthday as="date"}}' +
'{{field gender as="select" optionsBinding="formView.gender"}}' +
'{{form buttons name="Save post"}}'
),
save: function(data){
this.get('content').setProperties(data);
}
});
Just declare your form as a view extending EF.Form:
App.PostForm = EF.Form.extend({
contentBinding: 'App.someObject',
save: function(data){
this.get('content').setProperties(data);
}
});
Then create a handlebars layout more complex than that:
Right now only three field types are supported:
<input type='text' />
<textarea/>
<select/>
tag with options. Accepts:
- content: An array following ember's conventions
- optionValuePath: The name of the
property
that should be used as value. - optionLabelPath: The name of the
property
that should be used as label.
Three <select/>
tags representing day, month and year.
All the fields also accept the following options:
- name: Overrides the
name
attribute. - label: Overrides the label name
- Fork the project.
- Make your feature addition or bug fix.
- Add specs for it. This is important so we don't break it in a future version unintentionally.
- Commit, do not mess with rakefile, version, or history. If you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull.
- Send me a pull request. Bonus points for topic branches.
MIT License. Copyright 2011 Codegram Technologies