Skip to content

Instantly share code, notes, and snippets.

@mschwartz
Last active December 22, 2015 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mschwartz/6405021 to your computer and use it in GitHub Desktop.
Save mschwartz/6405021 to your computer and use it in GitHub Desktop.
SilkJS forms and Schema work together
<html>
<head>
</head>
<body>
<%
if (req.data.button) {
console.dir(req.data);
var example = {};
req.data.each(function(value, key) {
if (key.substr(0, 6) === 'field_') {
example[key.substr(6)] = value;
}
});
console.dir(example);
// maybe add:
// example.primaryKey = req.session.primaryKey;
// Schema.putOne('someTable', example);
}
%>
<form action="self">
test1 <input type="text" name="field_test1"><br/>
test2 <input type="text" name="field_test2"><br/>
test3 <input type="text" name="field_test3"><br/>
test4 <input type="text" name="field_test4"><br/>
test5 <input type="text" name="field_test5"><br/>
test6 <input type="text" name="field_test6"><br/>
<input type="submit" name="button" value="submit">
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment