使用autoform在流星中更新表格

问题描述:

我有一个处理表单默认值的集合。我需要构建一个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; 
    } 
    }); 
} 

更改此 从

<td>{{this.schemaName}}</td> 

<td>{{this.schema_name}}</td> 
+0

感谢约翰,怎么样永远,我不明白这将如何帮助。 schemaName是在mongodb级别以及架构级别定义的标签。我的意见是,如果我要执行您提到的更改,它实际上不会在模式名称列下填充任何内容。请您在这方面进一步阐述一些情况? – blueren

+0

你必须遵循json格式返回的一些数据结构标准.......... @blueren – Ankanna