- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建一个带有自动表单的表单,当我单击提交时,它会将新行(数据行)插入到集合中。我在此页面上找到了我想要的一个很好的示例,但我无法仅使用他们提供的解释/代码来使其工作。
http://autoform.meteor.com/insertaf
Schemas = {};
Template.registerHelper("Schemas", Schemas);
Schemas.Person = new SimpleSchema({
firstName: {
type: String,
index: 1,
unique: true
},
lastName: {
type: String,
optional: true
},
age: {
type: Number,
optional: true
}
});
var Collections = {};
Template.registerHelper("Collections", Collections);
People = Collections.People = new Mongo.Collection("People");
People.attachSchema(Schemas.Person);
Meteor.publish(null, function () {
return People.find();
});
People.allow({
insert: function () {
return true;
},
remove: function () {
return true;
}
<小时/>
{{#autoForm id="afInsertDemo" type="insert" collection=Collections.People}}
<div class="form-group {{#if afFieldIsInvalid name='firstName'}}has-error{{/if}}">
<label class="control-label">{{afFieldLabelText name='firstName'}}</label>
{{> afFieldInput name='firstName'}}
{{#if afFieldIsInvalid name='firstName'}}
<span class="help-block">{{{afFieldMessage name='firstName'}}}</span>
{{/if}}
</div>
<div class="form-group {{#if afFieldIsInvalid name='lastName'}}has-error{{/if}}">
<label class="control-label">{{afFieldLabelText name='lastName'}}</label>
{{> afFieldInput name='lastName'}}
{{#if afFieldIsInvalid name='lastName'}}
<span class="help-block">{{{afFieldMessage name='lastName'}}}</span>
{{/if}}
</div>
<div class="form-group {{#if afFieldIsInvalid name='age'}}has-error{{/if}}">
<label class="control-label">{{afFieldLabelText name='age'}}</label>
{{> afFieldInput name='age'}}
{{#if afFieldIsInvalid name='age'}}
<span class="help-block">{{{afFieldMessage name='age'}}}</span>
{{/if}}
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Add Person</button>
<button type="reset" class="btn btn-default">Reset Form</button>
</div>
{{/autoForm}}
我收到以下错误消息:
Template is not defined
最佳答案
在没有充分了解客户端、服务器端或两者上的定义的情况下开始使用简单的架构和自动表单可能是一个挑战。在您的情况下,您需要在客户端和服务器上都有架构和集合定义。服务器上的发布和收集访问规则以及客户端上的模板。
我创建了以下meteorpad项目来进行说明(注意“/client”、“/server”和“/common”前缀):
http://meteorpad.com/pad/Xue5BWFwcjyv4QvL2/AF%20Test
该项目有一个合理的结构可供遵循:
关于javascript - 如何设置 Meteor Insert AutoForm 将数据插入集合?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34002325/
我有一个用户架构,用户可能有一个团队列表,如本部分所示: "teams": { type: [Object], optional: true, autoform: { label:
我已经在架构中定义了一个对象数组,现在想要将对象属性显示到我的模板中,但不知道如何执行此操作。 ingredients: { type: [Object],
我正在创建一个用户管理面板,我的添加用户模式看起来很好,其中每个输入占据整行,下一个输入位于下一行。在我的编辑用户模式中,输入仅用了半行。以前有人见过这种行为吗? 添加用户模板: {{#auto
我想使用 Meteor 的自动表单包为我的 CAS_Entry 集合创建一个表单。代码如下所示。我还添加了定义的钩子(Hook),不幸的是,其中仅执行 beginSubmit 和 before ,并且
在 meteor 自动表单中(使用经典的 aldeed 包: https://github.com/aldeed/meteor-autoform ),我有一个名为 'score' 的隐藏字段,其值是另
如果某个选项已在其中一个对象组中被选中,我想将其禁用。 因此,如果我选择“2013”然后添加另一个示例,则“2013”在该组中将不可用,除非在原始组中更改该选项。 有没有一种我缺少的简单方法可
我正在为 MeteorJS 使用很棒的 aldeed:autoform 包。我有一个自定义表单,可以让我创建数据库条目。 用户输入的表单字段之一是郊区,我使用 sergeyt:typeahead 包在
我有带有文本字段的页面,这些字段是必需的。我单击带有空字段的“提交”=> 带有红色边框的字段(因为它是必需的)。然后我更改页面并返回 => 仍然显示边框。页面更改时如何重置 meteor AutoFo
我有一个包含以下字段的 Meteor AutoForm 集合架构,我正试图使其独一无二。它不允许在相同的情况下使用相同的值,但是当我更改值的大小写时,会插入值,那么如何防止插入具有不同大小写的重复值?
当使用 autoform 和 type="method-update"meteormethod="someMethod" 时,该方法实际上不会被调用。 我遇到问题的自动表单: {{#autoForm
我一直在寻找 SO 问题的答案,这些问题应该非常简单,但对于我来说我无法弄清楚。 基本上我有一个带有两个选择控件的 meteor-autoform: {{#autoForm id="proc
我一直在我的 Meteor 项目中使用 Collection2 和 Autoform,让事情变得简单多了! 但是,当我删除 insecure 时,它不再插入(Autoform 提交按钮)。我预料到
在我的 Stacks 架构中,我有一个 dimensions 属性定义如下: dimensions: { type: [String], autoform: { opt
我有一个像这样的快速表格: {{> quickForm schema=competitorSchema id="newCompetitorForm"type="method"buttonContent
我正在使用 Autoform 和 Slingshot 进行 S3 交互。当用户提交表单时,我想拦截进程,通过Slingshot上传文件到S3,扩展doc返回 downloadUrl 的对象然后此时,返
我们有一个站点,在不同的页面/路线上有几个 AutoForms。如果用户在特定表单上触发验证并触发一些验证错误,然后使用该表单离开页面,当他们稍后返回该页面时,他们输入的数据已经消失,但任何验证错误仍
我遇到了 aldeed:autoform 的问题我无法解决,也不明白原因是什么。模板: {{> quickForm collection=Cases id="inserNewItem" type
自从我找到了我一直在寻找的第一部分的答案以来,我正在对原始问题进行一些更新。 新问题: 到目前为止,我有一个架构定义,它附加到 3 个集合,即 C1、C2、C3。 some_schema = ne
我有一个 meteor 应用程序,我在其中使用 Aldeed: Autoform 根据架构将生成的表单直接插入到数据库中。有没有一种方法可以让我使用自己的自定义按钮或输入字段,而不是使用自动表单提供的
我正在构建一个新的 Meteor 应用程序,并尝试在使用 Simple Schema/Collection2/Autoform trifecta(以下称为 Collection2)运行还是使用替代的
我是一名优秀的程序员,十分优秀!