2016-11-06 9 views
0

流行のvalidatedmethodシンプルなスキーマとcollection2でautoformを使用しようとしています。私は、テキストフィールドに値を入力するときしかし、私が取得: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が表示されないので、この設定は実際には私のinsertメソッドを呼び出さないと思うが、流星はエラーで戻ってくる。どのようなアイデアが問題になるのでしょうか?

答えて

0

検索して試した後、私は属性meteormethodとtype属性を見つけました。これを設定すると、mdgで検証されたメソッドが呼び出されたように見えます。これを利用作成する方法を示し、以下を参照してください。その他の詳細については

{{#autoForm collection=club id="insertClubs" type="method" meteormethod="Clubs.methods.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}} 

を参照してください。https://github.com/aldeed/meteor-autoform#non-collection-forms

関連する問題