[英]Meteor AutoForm stops proceeding submit
我想使用流星的自動表單包為我的CAS_Entry
集合創建一個表單。 該代碼可以在下面看到。 我還添加了已定義的鈎子,不幸的是,其中的鈎子僅執行beginSubmit
和before
,並且沒有條目添加到集合中。 使用Meteor外殼,插入物就像一個飾物。
我很感謝任何提示。
addCasEntry.html,用於顯示表單的模板:
{{#autoForm collection="CAS_Entry" type="insert" id="addCasEntryForm"}}
{{> afQuickField name="type" options="allowed"}}
{{> afQuickField name="description" rows="6" type="textarea"}}
{{> afQuickField name="file" type="cfs-file" collection="Images"}}
{{> afQuickField name="date" }}
<button type="submit" class="btn btn-primary">Add</button>
{{/autoForm}}
addCasEntry.js,添加調試鈎子:
AutoForm.hooks({
addCasEntryForm: {
before: {
insert: function(doc) {
console.log(doc);
}
},
after: {
insert: function(error, result) {
console.log('Occured error: ' + error);
}
},
beginSubmit: function() {
console.log('begin submit');
},
onSuccess: function(formType, result) {
console.log("Insert succeeded");
console.log('Result ' + result);
},
onError: function(formType, error) {
console.log('Error!!!');
console.log(error);
}
}
});
SimpleSchema.debug = true;
/lib/collection/cas_entry.js:
CAS_Entry = new Mongo.Collection("cas_entries");
CAS_Entry.attachSchema(new SimpleSchema({
type: {
type: String,
allowedValues: ['reflection', 'evidence']
},
description: {
type: String,
optional: true
},
file: {
type: String,
optional: true,
},
timeUploaded: {
type: Date,
optional: true,
autoValue: function() {
return new Date();
}
},
date: {
type: Date,
}
}));
CAS_Entry.allow({
'insert': function() {
return true;
},
'update': function() {
return true;
}
});
這是控制台輸出:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.