Autoform Update:“vc.resetValidation不是函数”

时间:2016-12-12 16:51:06

标签: meteor meteor-autoform

我在

aldeed:collection2-core
aldeed:autoform
aldeed:schema-deny
npm simpl-schema

当我更新用户架构上的表单时,我收到错误vc.resetValidation is not a function。 表格有效提交 - 更新得很好。 我该如何解决这个错误?

这是我的查询

{{#autoForm collection='Meteor.users' doc=currentUser type='update' id='accountForm'}}
{{> afFieldInput name='profile.phone'}}
{{> afFieldInput name='profile.avatar'}}
<button type='submit' class="at-btn dark">Update</button>
{{/autoForm}}

以下是autoform代码的一部分,我认为存在验证问题

/// Reset array counts                                                                                              
arrayTracker.resetForm(formId);                                                                                                                                                                                                       var vc = AutoForm.getValidationContext(formId);                                                                    
if (vc) {                                                                                                          
  vc.resetValidation();                                                                                            
  // If simpleSchema is undefined, we haven't yet rendered the form, and therefore
  // there is no need to reset validation for it. No error need be thrown.
}                                                                                                                  
if (this.doc) {                                                                                                    
  event.preventDefault();                                                                                          
  AutoForm._forceResetFormValues(formId);                                                                          
}   

1 个答案:

答案 0 :(得分:0)

您可以从resetForm或实际上从onSubmit挂钩拨打onSuccess

AutoForm.addHooks(['form_id'], { 
     onSuccess: function(formType, result) { 
         this.resetForm() 
     } 
}) ;

Documentation