2017-02-09 37 views
0

我有一個自動窗體與此選項:沒有收到文件_id作爲自動窗體方法更新參數

{{ 
    #autoForm 
    collection=articulosColecction 
    id="articulos_modificar" 
    doc=articuloToModificar 
    type="method-update" 
    meteormethod="areas.update" 
    singleMethodArgument=true // Recommended here 
}} 

singleMethodArgument = TRUE推薦here

而且我的方法是這樣的:

export const update = new ValidatedMethod({ 
    name: 'areas.update', 
    validate: null, 
    run(doc) { 
    console.log(doc._id); 
    Areas.update({ _id: doc._id }, doc.modifier) 
    } 
}); 

documentation說:

  1. 如果將singleMethodArgument = true設置爲表單屬性,則將使用具有_id和修飾符屬性的單個對象參數調用您的方法。你應該這樣做,如果使用mdg:validated-method包。

但是console.log(doc._id);正在輸出undefined和我試圖`的console.log(DOC)」,並將其輸出僅修改器對象。

這是怎麼回事?我的AutoForm有問題嗎?

+0

我在'autoForm'表單的'collection'參數上有錯誤的集合。 –

回答

0

meteormethod參數應該調用Meteor.Method

你應該定義:

Meteor.methods({ 
    areas.update(updateData){ 
    check(updateData._id, String); 
    check(updateData.modifier, Object); 
    //do other stuff here 
    } 
}); 

可以使用data._id和修改的方法內。

相關問題