mongodb - Update form in meteor using autoform -
i have collection handles default values forms. need build ui update default values themselves, instead of force updating via mongo backed.
i've used aldeed's update-each functionality. data being fetched db , displayed in table. however, when try update inputting new values in textbox, not persist. in fact, keeps throwing error i'm not aware of.
exception in template helper: typeerror: cannot read property 'namedcontext' of undefined @ object.autoformfieldisinvalid
as sample, here i'm working with:
mongo collection:
meteor:primary> db.testcollection.find() { "_id" : objectid("577ccd87f57f43d790c3ec49"), "schemaname" : "test_schema", "label" : "test_lable", "value" : "test_value" }
schema:
test_schema = new simpleschema({ "schemaname": { type: string, }, "label": { type: string, }, "value": { type: string, } }); testcollection.attachschema(test_schema);
template:
<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>
helper
import { template } '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; } }); }
change
<td>{{this.schemaname}}</td>
to
<td>{{this.schema_name}}</td>
Comments
Post a Comment