Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Meteor从模式定义的表单中获取数据_Javascript_Meteor_Meteor Autoform - Fatal编程技术网

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')