I have an AutoForm with this options:
{{
#autoForm
collection=articulosColecction
id="articulos_modificar"
doc=articuloToModificar
type="method-update"
meteormethod="areas.update"
singleMethodArgument=true // Recommended here
}}
singleMethodArgument=true is Recommended here
And my method is this:
export const update = new ValidatedMethod({
name: 'areas.update',
validate: null,
run(doc) {
console.log(doc._id);
Areas.update({ _id: doc._id }, doc.modifier)
}
});
The documentation says:
- If you set singleMethodArgument=true as a form attribute, your method will be called with a single object argument with _id and modifier properties. You should do this if using the mdg:validated-method package.
But console.log(doc._id);
is outputting undefined
and I've tried `console.log(doc)' and it outputs only the modifier object.
What is going? Is it something wrong with my AutoForm?
meteormethod argument should call a Meteor.Method.
you should have define:
Meteor.methods({
areas.update(updateData){
check(updateData._id, String);
check(updateData.modifier, Object);
//do other stuff here
}
});
inside the method you can use the data._id and modifier.