Adding properties to form.values in _update function

15 views
Skip to first unread message

Schmidtchen Schleicher

unread,
Aug 13, 2013, 3:46:06 PM8/13/13
to ka...@googlegroups.com
I have built a form using couchtypes and want to add the username to the document in the _update function before saving it to the database. I tried it with
editForm.values.user = req.userCtx.name;
but it returned this error:
{"error":"forbidden","reason":"user: Unexpected property - validation 2"}

Here's my code:

var templates = require('duality/templates'),
Form = require('couchtypes/forms').Form,
recipe = require('./types').recipe;

exports.update_recipe = function(doc,req) {
var editForm = new Form(recipe);
editForm.validate(req);

if (editForm.isValid()) {
editForm.values.user = req.userCtx.name;
return [editForm.values, {content:"Yeah, Form valid!", title: "Validform"}];
}
};

Is this a kanso specific error?

Reply all
Reply to author
Forward
0 new messages