我正在我的流星项目中使用autoform并在我的表单中使用afArrayFieldfor my dimensionsfield NewStack.
它目前看起来像这样.
以下是它的呈现方式:
NewStack.html
<template name="NewStack">
<div class="new-stack-container">
{{#autoForm collection=stacks id="insertStackForm" type="method" meteormethod="createStack" class="new-stack-form"}}
<fieldset>
<legend>Add a Stack!</legend>
{{> afQuickField name='desc'}}
{{> afArrayField name='dimensions'}}
</fieldset>
<button type="submit" class="btn btn-primary">Insert</button>
{{/autoForm}}
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
我希望看到每个维度的字段是填充了我在模式设置的选项下拉(即dim1,dim2和dim3).但是我似乎无法将表单呈现为除纯文本输入之外的任何内容.
Stacks.js
StackSchema = new SimpleSchema({
desc: {
type: String,
label: "Description"
},
dimensions: {
type: [String],
autoform: {
type: "select",
afFieldInput: {
options: [
{label: "dim1", value: 1},
{label: "dim2", value: 2},
{label: "dim3", …Run Code Online (Sandbox Code Playgroud) 我是meteor和mongo db的新手.我正在使用meteor@1.3.4.1申请.我正在创建一个名为'/imports/api/collections/recipe.js'的文件.在这里,我创建一个集合并将此文件导入'/server/main.js'和'/client/main.js'.在recipe.js中,我只发布Recipe集合,然后在我的客户端文件中我订阅它.直到这一点,一切都是正确的.然后我使用autoform创建一个表单,它运行良好并创建.但这种形式永远不会发布.
首先,我的假设是当服务器启动时,那时我的数据库应该创建一个名为recipe的集合,但事实并非如此.
其次,为什么autoform不起作用?我认为这是因为第一个原因.
在客户端,我通过蒙古(流星玩具)看到我的食谱收藏.
我的食谱文件 - '/imports/api/collections/recipe.js':
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
var RecipesCollection = new Mongo.Collection('recipes');
RecipesCollection.allow({
insert(userId, doc){
return !!userId;
}
})
var RecipeSchema = new SimpleSchema({
name: {
type: String,
label: "Name"
},
desc: {
type: String,
label: "Description"
},
author: {
type: String,
label: "Author",
autoValue(){
return this.userId
},
autoform:{
type: "hidden"
}
},
createdAt: {
type: Date,
label: "Created At",
autoValue(){ …Run Code Online (Sandbox Code Playgroud) mongodb meteor meteor-blaze meteor-autoform meteor-collection2
我正在构建Meteor管理系统的一部分,让管理员添加/编辑其他管理员.我正在使用Meteor Accounts和Autoform,但我无法弄清楚如何处理它以便用户通过Autoform进行验证并正确保存.从我发现它看起来我需要使用该Accounts.createUser方法并使表单成为一个type="method"或什么,但我不知道如何处理或如果这是正确的方式.
这是我现在的代码:
架构:
Schema = {};
Schema.UserProfile = new SimpleSchema({
name: {
type: String,
label: "Name"
}
});
Schema.User = new SimpleSchema({
email: {
type: String,
regEx: SimpleSchema.RegEx.Email
},
password: {
type: String,
label: "Password",
min: 6
},
passwordConfirmation: {
type: String,
min: 6,
label: "Password Confirmation",
custom: function() {
if (this.value !== this.field('password').value) {
return "passwordMissmatch";
}
}
},
createdAt: {
type: Date,
autoValue: function() {
if (this.isInsert) {
return new Date;
} else …Run Code Online (Sandbox Code Playgroud) 我正在使用Meteor与AutoForm和铁路由器.
我有一个用于插入数据的autoform,我想重定向到成功插入后添加的数据页面.我该怎么办?
这是For:
{{#autoForm collection="Products" id="add" type="insert"}}
<h4 class="ui dividing header">Products Information</h4>
{{> afQuickField name='name'}}
{{> afQuickField name='info'}}
<button type="submit" class="ui button">Insert</button>
{{/autoForm}}
Run Code Online (Sandbox Code Playgroud)
铁路由器:
Router.route('/products/:_id', {
name: 'page',
data: function() { return Products.findOne(this.params._id);}
});
Run Code Online (Sandbox Code Playgroud)
回调/钩
AutoForm.hooks({
add: {
onSuccess: function(doc) {
Router.go('page', ???);
}
}
});
Run Code Online (Sandbox Code Playgroud) 我一直在我的Meteor项目上使用Collection2和Autoform,让事情变得容易多了!
但是,当我删除不安全时,它不再插入(Autoform提交按钮).我期待这个!
但是,我搜索过,我找不到让它工作的标准方法?我有lib文件夹中定义的架构,并自动创建窗体我作为一个template.i一个快速表单就知道我必须为允许客户端插入(我宁愿不做)或者其与传送到服务器端(也许方法?)
我们欢迎所有的建议!我正在寻找实现它的标准方法.
如何在Meteor中创建包含输入字段的表格.我使用了http://autoform.meteor.com/update-each中的示例,但它们只使用了1个输入字段.
该功能适用于此代码:
<tbody>
{{#each persons}}
{{#autoForm id=makeUniqueID type="update" collection=Collections.Persons doc=this autosave=true}}
<tr>
<td>{{> afFieldInput name="fullName" label=false}}</td>
<td>{{> afFieldInput name="email" label=false}}</td>
<td>{{> afFieldInput name="address" label=false}}</td>
<td><button type="submit" class="btn btn-xs btn-danger">Delete</button></td>
</tr>
{{/autoForm}}
{{/each}}
</tbody>
Run Code Online (Sandbox Code Playgroud)
但它<form>围绕每个创建了一个元素<tr>,它搞砸了我的HTML.这样做的正确方法是什么?
有一个用于bootstrap datetimepicker的Meteor包装器.在bootstrap文档中,您可以指定仅选择时间(#datetimepicker3).我想在Meteor中这样做.我试过用了
{{> afQuickField name="departureTime" dateTimePickerOptions=timePickerOptions}}
timePickerOptions : function() {
return {
format : 'LT'
}
},
Run Code Online (Sandbox Code Playgroud)
但是这仍然显示日历(虽然它确实允许您选择时间).这里有什么我想念的吗?
根据另一个字段动态显示子模式(Object)字段的最佳方法是什么?在以下示例中,文档(Schemas.Main)可以包含Schemas.Items中定义的多个项目.填写项目所需的字段取决于所选类型.
例如,如果用户选择type =="type1",则需要填写字段"type1_field1"和"type1_field2".
解决方案可能需要使用autoForm并结合AutoForm.getFieldValue和设置afArrayField的字段,对吗?我尝试了很多组合,但是添加其他项目的能力都丢失了(缺少加号)或者我无法添加不同的项目(即所有项目都是type1).任何提示如何解决这个问题?
//Schemas.js
Schemas = {}; Collections = {};
Main = Collections.Main = new Mongo.Collection("Main");
Main.attachSchema(Schemas.Main);
Meteor.isClient && Template.registerHelper("Schemas", Schemas);
Schemas.Main = new SimpleSchema({
name: {
type: String
},
items: {
type: [Schemas.Items]
}
});
Schemas.Items = new SimpleSchema({
type: { //FormActions...
type: String,
allowedValues: ['type1', 'type2', 'type3'],
autoform: {
type: "selectize"
}
},
type1_field1: {
type: String
},
type1_field2: {
type: String
},
type2_field1: {
type: String
},
type2_field2: {
type: String
},
type3_field1: {
type: String …Run Code Online (Sandbox Code Playgroud) 我有以下SimpleSchema,我试图添加自定义验证以验证输入重复的客户名称,但每当我尝试保存新客户时,我收到错误:
提供调用'adminCheckNewCustomerName'结果的异常:TypeError:无法读取null的'namedContext'属性
有人可以请告诉我我在做错了什么/在这里缺少来验证客户名称是否有重复记录?谢谢
schema.js:
AdminSection.schemas.customer = new SimpleSchema({
CustomerName: {
type: String,
label: "Customer Name",
unique: true,
custom: function() {
if (Meteor.isClient && this.isSet) {
Meteor.call("adminCheckNewCustomerName", this.value, function(error, result) {
if (result) {
Customer.simpleSchema().namedContext("newCustomerForm").addInvalidKeys([{
name: "CustomerName",
type: "notUnique"
}]);
}
});
}
}
}
});
UI.registerHelper('AdminSchemas', function() {
return AdminSection.schemas;
});
Run Code Online (Sandbox Code Playgroud)
form.html:
{{#autoForm id="newCustomerForm" schema=AdminSchemas.customer validation="submit" type="method" meteormethod="adminNewCustomer"}}
{{>afQuickField name="CustomerName"}}
<button type="submit" class="btn btn-primary">Save Customer</button>
{{/autoForm}}
Run Code Online (Sandbox Code Playgroud)
collections.js:
this.Customer = new Mongo.Collection("customers");
Run Code Online (Sandbox Code Playgroud) javascript meteor meteor-autoform meteor-collection2 simple-schema
从github,dateExample中提取工作示例.
我之前已经问过这个问题,但是这个建议没有用,所以我创建了一个小例子.如果有人可以指出我正确的方向,我可以在网上提出并发布链接.这是一个流星应用程序.
问题
Autoform生成带日期的表单.该表单作为一个数组工作,并使用引导程序模板,该模板提供一些+-按钮add或remove其他条目.当我使用aldeed:autoform-bs-datepicker表格内出现的奇怪问题时.如果您+-在保存之前输入日期并点击按钮,则日期将消失.如果你不使用autoform-bs-datepicker这个问题就消失了.
请参阅下面的代码,如果有办法,我可以在线发布示例,让我知道,我会这样做.
路径: packages.js
twbs:bootstrap
aldeed:collection2
aldeed:autoform
rajit:bootstrap3-datepicker
aldeed:autoform-bs-datepicker
Run Code Online (Sandbox Code Playgroud)
路径: Schemas.js
Classes = new Mongo.Collection("Classes");
var Schemas = {};
Schemas.DatesNotWorking = new SimpleSchema({
name: {
type: String,
optional: true
},
startDate: {
type: Date,
optional: true,
autoform: {
type: "bootstrap-datepicker",
"data-date-autoclose": "true",
datePickerOptions: {
format: "yyyy",
startView: "years",
minViewMode: "years"
}
}
},
endDate: {
type: Date,
optional: true,
autoform: {
type: "bootstrap-datepicker", …Run Code Online (Sandbox Code Playgroud) meteor ×10
meteor-autoform ×10
javascript ×4
iron-router ×2
meteor-blaze ×2
mongodb ×1
node.js ×1
schema ×1