Javascript Meteor从模式定义的表单中获取数据
我正在尝试设置一个表单,用于用户创建。架构的电子邮件部分设置为数组:Javascript Meteor从模式定义的表单中获取数据,javascript,meteor,meteor-autoform,Javascript,Meteor,Meteor Autoform,我正在尝试设置一个表单,用于用户创建。架构的电子邮件部分设置为数组: ... "emails.$.address": { type: String, blackbox: true }, "emails.$.verified": { type: Boolean, optional: true, blackbox: true }, ... 我使用“自动表单”在模板内部创建表单: {{#autoForm id="addUser" type="metho
...
"emails.$.address": {
type: String,
blackbox: true
},
"emails.$.verified": {
type: Boolean,
optional: true,
blackbox: true
},
...
我使用“自动表单”在模板内部创建表单:
{{#autoForm id="addUser" type="method" meteormethod="createUserwRole" collection="Users" schema=schema resetOnSuccess="true" }}
<fieldset>
{{> afQuickField name="fName" id="fName"}}
{{> afQuickField name="lName" id="lName"}}
{{> afQuickField name="username" id="username"}}
{{> afQuickField name="emails" id="emails"}}
{{> afFormGroup name="roles" options=options firstoption="Select Role" type="select-multiple" id="roles"}}
<div>
<button type="submit" class="btn btn-primary" data-toggle="modal" data-target="#addUser">Submit</button>
<button type="reset" class="btn btn-default">Reset</button>
</div>
</fieldset>
{{/autoForm}}
但尝试查找emails.0.address会返回错误:
TypeError: null is not an object (evaluating 't.find("#emails.0.address").value')
有太多的事情做得不对。请浏览简单模式和自动格式自述文件。这是一个非常强大的软件包,确实让很多事情变得更容易
对象时,才使用blackbox:true
collection=“Users”
schema=schema
,请仅指定一个AutoForm.hooks
而不是自定义事件侦听器
自动成形钩({
地址用户:{
onSubmit:函数(doc){
console.log(doc.emais[0].地址);
console.log(doc.username);
返回true;
}
}
});谢谢你纠正我的问题,我正在尝试让Autoform.hooks工作,并得到错误
ReferenceError:找不到变量:Autoform
有什么问题吗?嘿,应该是Autoform
-大写F。我得到相同的错误,但它的不同变体ReferenceError:找不到变量:Autoform
在哪里你在粘贴代码吗?哪个文件和哪个函数?它在if(meteor.isClient)
块的js文件中
TypeError: null is not an object (evaluating 't.find("#emails.0.address").value')