Open BehrouzRiahu opened 8 years ago
take a look at this : https://github.com/aldeed/meteor-autoform
I think need some reformatting. I am trying to figure out how it works everything.
Did you find any solution?
They have written all the documentation in CoffeeScript, so basically you should translate it in JavaScript if you are not running CoffeeScript.
By far this is in JS :
collections/posts.js ( or collection common.js file )
var Schemas = {};
Posts = new Meteor.Collection('posts');
Schemas.Posts = new SimpleSchema({
title:{
type: String,
max: 60
},
content:{
type: String,
min: 20,
max: 1000,
autoform: {
rows: 5
}
},
createdAt:{
type: Date,
label: "Date",
autoform:{
value: new Date()
}
},
owner: {
type: String,
regEx: SimpleSchema.RegEx.Id,
optional: true
autoValue: function(){
if (this.isInsert)
return Meteor.userId()
},
autoform:{
type: "select",
options: function(){
return _.map(Meteor.users.find().fetch(), function(user) {
return {
label: user.emails[0].address,
value: user._id
};
});
}
}
}
});
Posts.attachSchema(Schemas.Posts);
In lib/admin_config.js
AdminConfig = { collections: { Posts: {} } };
When I try and add the Posts collection as it is shown int he package example as follows:
I get back the following error: "Leading decorators must be attached to a class declaration"
What am I doing wrong here?
And is it possible to play around with the design the content of the
/admin
content? because I couldn't figure out how, I would appreciate it if someone could confirm it for me before I start using it :)