i’m doing a simple system to culculate built of material. found most of the tutorial recomended to use aldeed:autoform. however, after gone through the tutorial, its all back dated to 2015. is there anyone can guide me how to include this aldeed:autoform in my web application.
currently i’m following this youtube https://www.youtube.com/watch?v=2mZGCrRkTEQ&t=368s and try to make it work.
Sorry i’m new in meteor and coding world.
Although dated as of 2015, it still valid (99%), so you can follow the tutorial that it’s going to be okay. Just use imports.
Is this mean the collection is replace by import?
I have this error on my meteor
W20170130-07:47:54.361(8)? (STDERR) TypeError: Cannot read property 'insert' of undefined
W20170130-07:47:54.361(8)? (STDERR) at meteorInstall.imports.api.recipies-schema.js (imports/api/recipies-schema.js:2:1)
This is my schema under /imports/api
export const Recipies = new Mongo.Collection('recipies');
Recipies.after.insert(function (userId, doc) {
console.log('server receipies after hook /w', doc.guest);
});
Recipies.attachSchema(new SimpleSchema({
guests: {
type: String,
label: "Name of Guest",
optional: false,
min: 5,
max: 80
},
restrictions: {
type: String,
label: "Dietary Restriction",
optional: true,
max: 250,
autoform: {
rows:4
}
},
email:{
type: String,
regEx: SimpleSchema.RegEx.Email,
label: "Email",
optional: true
},
createdAt: {
type: Date,
autoValue: function () {
return new Date();
}
}
}));
Recipies.allow({
insert: function (userId,doc) {
return true;
},
update: function (userId, doc, fields, modifier) {
return true;
},
remove: function (userId, doc) {
return true;
}
});
and this is my template
<template name="addRecipies">
<div class="new-recipe-container">
{{> quickForm
Collection="Recipies"
id="insertRecipiesForm"
type="method"
meteormethod="submitRecipies"
omitFields="createdAt"
}}
</div>
</template>
sorry, this is my method
import { Estimate } from './estimate';
import { Customer } from './customer';
Meteor.methods({
'estimate.addEstimate' (newEstimate) {
if (!Meteor.userId()) { throw new Meteor.Error('not-authorized');}
newEstimate.owner = Meteor.userId();
newEstimate.createdAt = new Date();
Estimate.insert(newEstimate);
},
'customer.addCustomer' (newCustomer) {
if (!Meteor.userId()) { throw new Meteor.Error('not-authorized');}
newCustomer.owner = Meteor.userId();
newCustomer.createdAt = new Date();
Customer.insert(newCustomer);
},
'Recipies.addRecipies' (newRecipies) {
if (!Meteor.userId()) { throw new Meteor.Error('not-authorized');}
newCustomer.owner = Meteor.userId();
newCustomer.createdAt = new Date();
Recipies.insert(recipies);
}
});
i have edit and remove the recipies.after.insert as per below only and error is gone.
export const Recipies = new Mongo.Collection('recipies');
Plus i have enable the import at method as per below
import { Estimate } from './estimate';
import { Customer } from './customer';
import { Recipies } from './recipies-schema';
But the form not shown up and receive this error at my chrome
Exception in template helper: TypeError: Cannot read property 'schema' of undefined
at Object.quickFormContext (http://localhost:3000/packages/aldeed_autoform.js?hash=62240ad3bd09e4bcabcb996180d4d6ec136db9a9:6713:34)
at
i have define the schemabut it mention cannot read. can anyone guide me please.
Apprently there is nothing wrong with AutoForm, but your Collection object is undefined, that’s why it’s isn’t working. Try to fix the imports.
is this the one to define it?
which ‘id’ this blazeview mention?
TypeError: Cannot read property 'id' of null
at Blaze.View.<anonymous> (aldeed_autoform.js?hash=62240ad…:6551)
at blaze.js?hash=983d07a…:1875
at Function.Template._withTemplateInstanceFunc (blaze.js?hash=983d07a…:3687)
at blaze.js?hash=983d07a…:1873
at Object.Blaze._withCurrentView (blaze.js?hash=983d07a…:2214)
at viewAutorun (blaze.js?hash=983d07a…:1872)
at Tracker.Computation._compute (tracker.js?hash=9f8a0ce…:339)
at new Tracker.Computation (tracker.js?hash=9f8a0ce…:229)
at Object.Tracker.autorun (tracker.js?hash=9f8a0ce…:604)
at Blaze.View.autorun (blaze.js?hash=983d07a…:1885)