Templates Meteor自动形成自定义模板

Templates Meteor自动形成自定义模板,templates,meteor,meteor-autoform,Templates,Meteor,Meteor Autoform,这是一个利基之一-希望有人有一些经验,这之前!任何指点都将不胜感激 问题 我正在尝试将Autoform与Autoform语义UI和嵌套的自定义模板一起使用。在接口中,加载外部表单,但当加载自定义模板时,控制台出现错误,表示模板无法访问任何数据,例如: debug.js:41 Exception in template helper: TypeError: Cannot read property 'type' of undefined at afArrayTracker.atInitField

这是一个利基之一-希望有人有一些经验,这之前!任何指点都将不胜感激

问题 我正在尝试将Autoform与Autoform语义UI和嵌套的自定义模板一起使用。在接口中,加载外部表单,但当加载自定义模板时,控制台出现错误,表示模板无法访问任何数据,例如:

debug.js:41 Exception in template helper: TypeError: Cannot read property 'type' of undefined
at afArrayTracker.atInitField [as initField]

Exception in template helper: TypeError: Cannot read property 'slice' of null
at Object.autoFormGetLabelForField [as getLabelForField]

Exception in template helper: Error: Invalid field name: (not a string)
at Object.getDefs
这使得我的表单只呈现了一部分

代码 client.js具有模式设计:

Schemas = {};

Template.registerHelper("Schemas", Schemas);

Schemas.MarkingScheme = new SimpleSchema({
    name: {
      type: String,
      optional: false
    },
    description: {
      type: String,
      optional: true
    },
    aspects: {
        type: Array
    },
    'aspects.$': {
      type: Object
    },
    'aspects.$.focus': {
        type: String
    },
    'aspects.$.rubric': {
        type: Array,
        minCount: 1
    },
    'aspects.$.rubric.$': {
      type: Object
    },
    'aspects.$.rubric.$.mark': {
        type: Number
    },
    'aspects.$.rubric.$.criteria': {
        type: String,
        optional: true
    },
    comments: {
        type: [String],
        optional: true
    }
});
下面是表单的模板,它可以正常工作:

<template name="insertScheme">
  <div class="ui large header">New Marking Scheme</div>
    {{#autoForm schema=Schemas.MarkingScheme id="insertScheme" type="insert"}}
      {{> afQuickField name="name"}}
      {{> afQuickField name="description"}}

      {{> afArrayField name="aspects" template="rubric"}}

      {{> afQuickField name="comments"}}
      <div class="row">
        <div class="centered column">
          <div class="two large ui buttons">
            <button type="reset" class="ui button">Clear</button>
            <div class="or"></div>
            <button type="submit" class="positive ui button">Submit</button>
          </div>
        </div>
      </div>
  {{/autoForm}}
</template>

新评分制度
{{{#autoForm schema=Schemas.MarkingScheme id=“insertScheme”type=“insert”}
{{>afQuickField name=“name”}
{{>afQuickField name=“description”}
{{>afArrayField name=“aspects”template=“rubric”}
{{>afQuickField name=“comments”}
清楚的
提交
{{/autoForm}
现在情况变得更糟了,尽管我已恢复使用语义ui自动表单包所用模板的近似复写版本:

<template name="afArrayField_rubric">
  <h4 class="ui top attached block header">
    {{afFieldLabelText name=this.atts.name}}
  </h4>
  <div class="ui secondary bottom attached segment">
    {{#if afFieldIsInvalid name=this.atts.name}}
      <div class="ui pointing red basic label">
        {{{afFieldMessage name=this.atts.name}}}
      </div>
    {{/if}}
    {{#afEachArrayItem name=this.atts.name minCount=this.atts.minCount maxCount=this.atts.maxCount}}
      <div class="field autoform-array-item">
        {{#if afArrayFieldHasMoreThanMinimum name=../atts.name minCount=../atts.minCount maxCount=../atts.maxCount}}
          <div class="ui mini red corner label autoform-remove-item">
            <i class="icon minus"></i>
          </div>
        {{/if}}
        {{> afArrayField name=this.name label=false options=afOptionsFromSchema template="aspects"}}
      </div>
    {{/afEachArrayItem}}
    {{#if afArrayFieldHasLessThanMaximum name=this.atts.name minCount=this.atts.minCount maxCount=this.atts.maxCount}}
      <div class="field">
        <div class="ui small green icon button autoform-add-item" data-autoform-field="{{this.atts.name}}" data-autoform-minCount="{{this.atts.minCount}}" data-autoform-maxCount="{{this.atts.maxCount}}">
          <i class="icon plus"></i>
        </div>
      </div>
    {{/if}}
  </div>
</template>

{{AffielLabelText name=this.atts.name}
{{#如果afFieldIsInvalid name=this.atts.name}
{{{afFieldMessage name=this.atts.name}}
{{/if}
{{{#afEachArrayItem name=this.atts.name minCount=this.atts.minCount maxCount=this.atts.maxCount}
{{#如果afarrayFieldhasmorethan最小名称=../atts.name minCount=../atts.minCount maxCount=../atts.maxCount}
{{/if}
{{>afArrayField name=this.name label=false options=a选项fromschema template=“aspects”}
{{/afEachArrayItem}
{{#如果afArrayFieldHasLessThanMaximum name=this.atts.name minCount=this.atts.minCount maxCount=this.atts.maxCount}
{{/if}
这个想法是,它会更深入;但这是我们所能做到的


非常感谢您提出的任何想法

你安装了Collection2软件包吗?我最初没有这个软件包,但现在安装了。没有神奇的修复;但是有什么方法我应该使用它吗?Collection2允许您将对象/模式添加到mongo,并自动进行验证。听起来不错。我会仔细阅读的,谢谢!你安装了Collection2软件包吗?我最初没有这个软件包,但现在安装了。没有神奇的修复;但是有什么方法我应该使用它吗?Collection2允许您将对象/模式添加到mongo,并自动进行验证。听起来不错。我会仔细阅读的,谢谢!