0

我在使用更新自动表单时遇到客户端异常(如下)。我完全不知道如何调试这个问题。请注意,集合中的文件创建得很好。只是在客户端控制台中引发了此异常。抱歉,如果这是一个菜鸟问题。

客户表格:

{{#autoForm class="editf" id="editf" collection="ServiceProviders" type="update" doc=selectedProvider}} 
{{> afQuickField name="businessname"}} 
{{> afQuickField name="businessdesc"}}
<button type="submit" class="btn btn-primary">Update your profile</button>
{{/autoForm}}

帮手:

 Template.createprovider.events = {
'submit .editf' : function(e) {
    event.preventDefault();
    Router.go('/createdprovider');
    AutoForm.resetForm('editf');
}

};

收集挂钩:

ServiceProviders.after.update(function (userId, doc) {
  Meteor.call('UpdateAddressAndLocation', userId, doc);
});

例外:

Exception in delivering result of invoking '/serviceproviders/update': TypeError: Cannot read property 'reset' of undefined
at Object.autoFormResetForm [as resetForm] (http://localhost:3000/packages/aldeed_autoform.js?b2b90d28d5cc29be68358bb3c8bb8a337992a7dd:2127:26)
at autoFormActionCallback (http://localhost:3000/packages/aldeed_autoform.js?b2b90d28d5cc29be68358bb3c8bb8a337992a7dd:6494:22)
at CollectionHooks.defineAdvice.args.(anonymous function) (http://localhost:3000/packages/matb33_collection-hooks.js?6be355737d1b00b2f05a3c833db2d77cd78d8d47:419:23)
at wrappedCallbackForParsingServerErrors (http://localhost:3000/packages/aldeed_collection2.js?fdc7f0975dd1b3446ea4afd5f820cb1242a521af:455:15)
at _.each.Mongo.Collection.(anonymous function).wrappedCallback (http://localhost:3000/packages/mongo.js?3cfe0c5981c197df33036a37574850f057e934a6:621:9)
at Meteor.bindEnvironment [as _callback] (http://localhost:3000/packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf:983:22)

编辑:工作代码: 这需要与提交挂钩一起放置。this.done()调用成功。

onSuccess: function(doc, result) {
        Router.go('/createdprovider');
    }
4

1 回答 1

0

Autofrom has its own properties .... You cannot use autoform id to get values on submission.

Example:

AutoForm.hooks({
  YourFormid: {
    onSubmit: function (doc) {
      PeopleSchema.clean(doc);
      console.log("People doc with auto values", doc);
      this.done();
      return false;
    }
  }
});

This is the correct way to use hooks and use "doc=this"

于 2015-04-24T08:14:03.463 回答