Last active
December 22, 2015 02:39
-
-
Save mschwartz/6405021 to your computer and use it in GitHub Desktop.
SilkJS forms and Schema work together
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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