小编SLR*_*LRM的帖子

MeteorJS AutoForm.Hooks不更新文档

我正在为MeteorJS使用出色的aldeed:autoform包。我有一个自定义表单,可让我创建数据库条目。

用户输入的表单字段之一是Suburb的字段,我正在使用sergeyt:typeahead包在用户输入时对此提出建议。

这些建议采用用户熟悉的格式(本质上是“郊区,州/省,邮政编码”)。我称这个长郊区。

然后,我在钩子之前使用AutoForm从用户选择/输入的longsuburb值中分离出一个Zipcode(“邮政编码”)值和一个“ suburb”值。然后,钩子会在提交文档之前将郊区和邮政编码值插入到文档中。

这一切都很好。

现在,我想创建一个“编辑”表单,用户可以在其中编辑详细信息(我打算在这行中为这两个表单使用相同的表单,但这对我来说是一次,因为我是新手,所以这一次)。

我已经设置了一个“编辑”表单模板,并按照AutoForm示例将类型设置为“ update”。

我可以成功地编辑所有表单详细信息,并将它们保存到集合中,只是我的AutoForm钩子似乎根本没有被调用,因此文档的“郊区”和“邮政编码”值在提交时保持不变。

我尝试了几种不同的方法,但是大部分时间都是在黑暗中进行拍摄,因此任何建议都是不错的选择。

这是编辑表单模板

    <template name="editBar">
  {{#autoForm collection="Bars" id="editBarsForm" template="bootstrap3-horizontal" label-class="col-sm-3" input-col-class="col-sm-9" type="update" doc=this}}
  <fieldset>
    <legend>Edit Bar</legend>
    {{> afQuickField name='bar_name' placeholder="Name of the Bar, Pub, Venue" class="form-control typeahead" }}
    {{> afQuickField name='image' class="form-control typeahead" }}
    {{> afQuickField name='url' placeholder="Venue's Website" class="form-control typeahead" }}
    {{> afQuickField name='longsuburb' placeholder="Suburb" class="form-control typeahead" autocomplete="off" spellcheck="off" data-source="getSuburbs"}}
    {{> afQuickField name='barType' options=bartypes class="selectpicker"}}
  </fieldset>
  <button type="submit" class="btn btn-primary submit">Submit</button>
    <a class="btn btn-danger delete" href="#">Delete post</a>
    <a class="btn btn-default …
Run Code Online (Sandbox Code Playgroud)

hook meteor meteor-autoform

3
推荐指数
1
解决办法
1263
查看次数

标签 统计

hook ×1

meteor ×1

meteor-autoform ×1