Skip to content

Instantly share code, notes, and snippets.

@jshirley
Created August 17, 2012 15:27
Show Gist options
  • Select an option

  • Save jshirley/3379888 to your computer and use it in GitHub Desktop.

Select an option

Save jshirley/3379888 to your computer and use it in GitHub Desktop.
/*
*/
var template = Y.Handlebars.compile('{{{ render_form form }}}'),
goal = this.get('model'),
output = template(
{
form : {
/**
Values is a short-hand, it just sets values for each of the elements below correctly.
**/
values : goal.toJSON(),
/**
Define the fields as an array, you can also pass in `error` as a key and it displays errors.
**/
fields : [
{ label : 'Goal', name : 'name', required : true },
{ label : 'More', name : 'description' },
{ label : 'Category', name : 'category_id', type : 'select', options : categories },
{ label : 'Color', inputClassNames : [ 'color-input', 'color-swatch' ], name : 'color' },
{ label : 'Privacy', name : 'public', type : 'options', options : [
{ 'name' : 'public', 'value' : 1, label : 'Public (based on your account privacy settings)', type : 'radio' },
{ 'name' : 'public', 'value' : 0, label : 'Private (only you can see)', type : 'radio' }
] }
],
buttons : [
{ classNames : 'btn', label : 'Cancel', link : '/' },
{ classNames : [ 'btn', 'btn-primary' ], label : 'Save' }
]
}
},
{
partials : this.partials
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment