0
我想使用autoform与流星validatedmethod简单模式和collection2。然而,当我在文本框输入值,我得到:使用aldeed:autoform我得到访问被拒绝
undefined error:403
errorType:"Meteor.Error"
message:"Access denied [403]"
reason:"Access denied"
stack:"Error↵ at Connection._livedata_result http://localhost:3000/packages/ddp-client.js`
我的代码使用下面的模板:
{{#autoForm collection=club id="insertClubs" type="insert"}}
<fieldset>
<legend>Add a Club</legend>
{{> afQuickField name='name'}}
{{> afQuickField name='number'}}
{{> afQuickField name='updated'}}
{{> afQuickField name='created'}}
</fieldset>
<button type="submit" class="btn btn-primary">Insert</button>
{{/autoForm}}
然后我使用的是事件帮手听提交并调用validatedmethod:
submit .btn btn-primary'(event, instance) {
console.log('test');
insert.call({
name: 'test',
number: 3,
updated: new Date(),
created: new Date()
}, (err, res) => {
console.log(err);
});
}
,这是插入调用本身:
export const insert = new ValidatedMethod({
name: 'Clubs.methods.insert',
validate: Clubs.simpleSchema().validator(),
run(newClub) {
// In here, we can be sure that the newClub argument is
// validated.
console.log('insert new club');
if (!this.userId) {
throw new Meteor.Error('Clubs.methods.insert.not-logged-in',
'Must be logged in to create a club.');
}
Clubs.insert(newClub)
}
});
我认为这个设置实际上并没有调用我的插入方法,因为我没有看到console.log,但流星返回了错误。任何想法可能是什么问题?