1

我在我的项目中使用 autoform 并在打开表单时收到此错误 不确定这是否是因为任何版本或依赖项,我的 autoform 无法正常工作并且我收到此错误,我有屏幕截图和架构代码,表单下面的代码,

在此处输入图像描述

模板

<template name="assesmentNew">
  {{#ionModal customTemplate=true}}
    {{# autoForm collection="Assesments" id="assesments-new-form" type="insert"}}
      <div class="bar bar-header bar-stable">
        <button data-dismiss="modal" type="button" class="button button-clear">Cancel</button>
        <h2 class="title">New Assesment</h2>
        <button type="submit" class="button button-positive button-clear">Save</button>
      </div>
      <div class="content has-header overflow-scroll">
        {{> afQuickField name="name" }}
        {{> afQuickField name="email"}}
        {{> afQuickField name="category"}}
        {{> afQuickField name="location"}}
      </div>
    {{/autoForm}}
  {{/ionModal}}
</template>

收藏

Assesments = new Mongo.Collection('assesments');
Assesments.before.insert(function (userId, doc) {
  doc.createdAt = new Date();
});


Assesments.attachSchema(new SimpleSchema({
  name: {
   type: String,
    label: 'First Name',
    autoform: {
      'label-type': 'floating',
      placeholder: 'First Name'
    }
  },
  email: {
    type: String,
    label: 'Email',
    autoform: {
      'label-type': 'floating',
      placeholder: 'Email'
  }
  },
  category: {
    type: String,
      label: 'Category',
    optional: true,
    autoform: {
      options: [
        {value: 'General', label: 'General'},
        {value: 'Reported', label: 'Reported'},
        {value: 'Follow Up', label: 'Follow Up'}
      ],
      type: 'select-radio'
    }
  },
 assesmentDate: {
    type: Date,
    label: 'Assesment Date',
    optional: true
  },
  location: {
    type: String,
      label: 'Location',
      autoform: {
      'label-type': 'floating',
      placeholder: 'Location'
    },
    max: 200
  },
 createdBy: {
    type: String,
    autoValue: function() {
    return this.userId
  }
}
  }
    ));

if (Meteor.isServer) {
  Assesments.allow({ 
    insert: function (userId, doc) {
      return true;
    },
    update: function (userId, doc, fieldNames, modifier) {
      return true;
    },
    remove: function (userId, doc) {
      return true;
    }
  });
}
4

1 回答 1

1

这是新版本 autoform 的 autoform-ionic 新补丁的问题。

显然有些标签被跳过了,有些则没有(见这里)。为了解决这个问题并在您的输入类型不存在时避免此错误(例如,type = number),您的所有由 autoform 呈现的模式字段都必须定义一个标签类型选项:

...
autoform: {
   'label-type': 'placeholder',
   placeholder: 'Linha'
}
于 2015-06-16T03:07:05.783 回答