JavaScript Powered Forms for Ember.js
ember-formly is an Ember.js addon based on angular-formly
The aim isn't to fully duplicate angular-formly's functionality, but instead to propose a new & simplified mechanism for automating form creation by using patterns like components (instead of custom directives) while keeping some key concepts like model
and fields
.
ember install ember-formly
model() {
return {
age: 20,
veggie: true,
favcolor: '#0000ff',
borndate: '1986-11-14'
}
},
fields: computed(function() {
return [
{
key: 'age',
component: 'custom-fields/html-input',
options: {
type: 'number',
label: 'Age'
}
},
{
key: 'veggie',
component: 'custom-fields/html-input',
options: {
type: 'checkbox',
label: 'Is a Veggie?'
}
},
{
key: 'favcolor',
component: 'custom-fields/html-input',
options: {
type: 'color',
label: 'Favorite Color'
}
},
{
key: 'borndate',
component: 'custom-fields/date-picker',
options: {
label: 'Born Date'
}
}
]
})
Apply a class
to each field
:
Use custom markup for each field:
const fields = [
{
key: 'date',
component: 'date-picker',
options: {
label: 'Pick a date!',
callback: function(value) {
window.alert('Selected date: ' + value);
}
}
}
];
date-picker.js:
git clone
this repositorynpm install
bower install
ember server
- Visit your app at http://localhost:4200.
npm test
(Runsember try:testall
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli, visit http://ember-cli.com/.