简体   繁体   English

如何使用Meteor AutoForm和SimpleSchema引用afFormGroup中的emails。$。address?

[英]How to reference emails.$.address within afFormGroup using Meteor AutoForm and SimpleSchema?

I've search high and low, and the best I've seen is this example using afQuickField . 我已经搜索了很多东西,而我看到的最好的例子是使用afQuickField的例子 I really don't want to create "special" schemas just to be able to submit an email while creating a new Meteor user using AutoForm with SimpleSchema. 我真的不想创建“特殊”模式, 只是为了能够在使用带有SimpleSchema的AutoForm创建新的Meteor用户时提交电子邮件。

What is the exact way to create a form using AutoForm that I can use to create a new user in Meteor manually by calling Meteor.createUser() server-side? 使用AutoForm创建表单的确切方法是什么 ,我可以通过调用服务器端Meteor.createUser()在Meteor中手动创建新用户?

I understand how to use form hooks on submit...how to use afArrayField... but I just want to pass a value for emails.$.address from a form using afFormGroup ... how?? 我知道如何在提交时使用表单挂钩...如何使用afArrayField ...但是我只想通过afFormGroup从表单传递emails.$.address的值...如何?

I've tried... 我试过了...

{{> 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"}}

...all to no avail. ...全部无济于事 Seems like this is common enough that it should be simple. 似乎这种情况很普遍,应该很简单。

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

When I submit using the pattern in the link and last example above, I get an error that states "emails must be an array". 当我在上面的链接和上一个示例中使用模式提交时,出现错误,指出“电子邮件必须是数组”。

The correct way to index the first array element in this case is emails.0.address . 在这种情况下,索引第一个数组元素的正确方法是emails.0.address Have a look at the autoform docs: http://autoform.meteorapp.com/update-array-item . 看看自动表单文档: http : //autoform.meteorapp.com/update-array-item Also this thread might be of interest for you: https://github.com/aldeed/meteor-autoform/issues/200 . 另外,您可能对此线程感兴趣: https : //github.com/aldeed/meteor-autoform/issues/200

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM