0
我有一個處理表單默認值的集合。我需要構建一個UI來更新默認值,而不是通過支持mongo的強制更新。使用autoform在流星中更新表格
我已經使用aldeed的更新 - 每個功能。數據正從數據庫中提取並顯示在表格中。但是,當我嘗試通過在文本框中輸入新值進行更新時,它不會持續。事實上,它一直拋出這個我不知道的錯誤。
Exception in template helper: TypeError: Cannot read property 'namedContext' of undefined
at Object.autoFormFieldIsInvalid
爲樣本,這裏就是我的工作:
蒙戈集合:
meteor:PRIMARY> db.testCollection.find()
{ "_id" : ObjectId("577ccd87f57f43d790c3ec49"), "schemaName" : "test_schema", "label" : "test_lable", "value" : "test_value" }
模式:
test_schema = new SimpleSchema({
"schemaName": {
type: String,
},
"label": {
type: String,
},
"value": {
type: String,
}
});
testCollection.attachSchema(test_schema);
特mplate:
<template name = "testTemplate">
<table class="table table-bordered table-condensed">
<thead>
<tr>
<td style="width: 85px">Schema Name</td>
<td style="width: 85px">Label</td>
<td>Default Value</td>
<td style="width: 250px">New Default Value</td>
</tr>
</thead>
<tbody>
{{#each items}}
<tr>
<td>{{this.schemaName}}</td>
<td>{{this.label}}</td>
<td>{{this.value}}</td>
<td>
{{#autoForm id=updateDefaiultsID type="update" collection=testCollection doc=this autosave=true}}
{{> afFormGroup name="value" label=false}}
{{/autoForm}}
</td>
</tr>
{{/each}}
</tbody>
</table>
</template>
助手
import { Template } from 'meteor/templating';
import '../templates/testTemplate.html';
if (Meteor.isServer) {
Meteor.publish(null, function() {
return testCollection.find();
});
testCollection.allow({
update: function() {
return true;
}
});
}
else if (Meteor.isClient) {
Template["testTemplate"].helpers({
items: function() {
return testCollection.find({}, {sort: {name: 1}});
},
updateDefaiultsID: function() {
return "testTemplate" + this._id;
}
});
}
感謝約翰,怎麼樣永遠,我不明白這將如何幫助。 schemaName是在mongodb級別以及架構級別定義的標籤。我的意見是,如果我要執行您提到的更改,它實際上不會在模式名稱列下填充任何內容。請您在這方面進一步闡述一些情況? – blueren
你必須遵循json格式返回的一些數據結構標準.......... @blueren – Ankanna