【问题标题】:How to reference emails.$.address within afFormGroup using Meteor AutoForm and SimpleSchema?如何使用 Meteor AutoForm 和 SimpleSchema 在 afFormGroup 中引用 emails.$.address?
【发布时间】:2016-06-14 14:56:04
【问题描述】:

我搜索了高低,我见过的最好的是this example using afQuickField。我真的不想创建“特殊”模式只是能够在使用 AutoForm 和 SimpleSchema 创建新 Meteor 用户时提交电子邮件。

使用 AutoForm 创建表单的确切方法是什么,我可以通过调用 Meteor.createUser() server-side 在 Meteor 中手动创建新用户?

我了解如何在提交时使用表单挂钩...如何使用 afArrayField...但我只想从使用 afFormGroup 的表单中传递 emails.$.address 的值...如何??

我试过了……

{{> afFormGroup name="emails[0].address" type="text" label=false placeholder="schemaLabel" formgroup-class="o-group"}}
{{> afFormGroup name="emails.[].address" type="text" label=false placeholder="schemaLabel" formgroup-class="o-group"}}
{{> afFormGroup name="emails.$.address" type="text" label=false placeholder="schemaLabel" formgroup-class="o-group"}}
{{> afFormGroup name="emails.address" type="text" label=false placeholder="schemaLabel" formgroup-class="o-group"}}

...一切都无济于事。看起来这很常见,应该很简单。

{{> afFormGroup name="emails" type="text" label=false placeholder="schemaLabel" formgroup-class="o-group"}}

当我使用链接和上面最后一个示例中的模式提交时,我收到一条错误消息,指出“电子邮件必须是一个数组”。

【问题讨论】:

    标签: javascript meteor meteor-autoform


    【解决方案1】:

    在这种情况下,索引第一个数组元素的正确方法是emails.0.address。查看 autoform 文档:http://autoform.meteorapp.com/update-array-item。您也可能对这个线程感兴趣:https://github.com/aldeed/meteor-autoform/issues/200

    【讨论】:

      猜你喜欢
      • 2020-09-26
      • 2016-06-19
      • 2016-01-08
      • 1970-01-01
      • 1970-01-01
      • 2016-02-08
      • 2015-09-20
      • 2017-06-29
      • 2017-09-24
      相关资源
      最近更新 更多