Javascript 自动形成插入字段和
Meteor和AutoForm是否可能(以及如何)在数据库中插入依赖于相同表单中其他字段的总和字段,以及要隐藏的总和字段,例如orderSum字段 orderSum=orderLength+orderLayers file.jsJavascript 自动形成插入字段和,javascript,mongodb,meteor,Javascript,Mongodb,Meteor,Meteor和AutoForm是否可能(以及如何)在数据库中插入依赖于相同表单中其他字段的总和字段,以及要隐藏的总和字段,例如orderSum字段 orderSum=orderLength+orderLayers file.js Order = new Meteor.Collection("order", { schema: { 'orderLayers': { type: Number, label: "Layers", optional
Order = new Meteor.Collection("order", {
schema: {
'orderLayers': {
type: Number,
label: "Layers",
optional: false,
decimal: true,
min: 0
},
'orderLength': {
type: Number,
label: "Length",
optional: false,
decimal: true,
min: 0
}
}
});
file.html
{{> quickForm collection="Order" id="insertOrderForm" type='insert' buttonContent="Add Order"}}
谢谢。如果只想显示SimpleSchema中的部分字段,请使用选项
字段
:
<template name="form">
{{> quickForm fields='orderLayers,orderLength' collection="Order" id="insertOrderForm" type='insert' buttonContent="Add Order"}}
</template>
如果要快速测试上述内容,请克隆:
是否已弃用
同级字段?我不能用它此
仅返回{name:$.name}
Order = new Meteor.Collection("order", {
schema: {
'orderLayers': {
type: Number,
label: "Layers",
optional: false,
decimal: true,
min: 0
},
'orderLength': {
type: Number,
label: "Length",
optional: false,
decimal: true,
min: 0
},
'orderSum': {
type: Number,
optional: false,
decimal: true,
autoValue:function(){
var result = this.siblingField("orderLength").value +this.siblingField("orderLayers").value;
console.log(result);
return result
}
}
}
});