Created
April 23, 2013 19:52
-
-
Save dhigginbotham/5446844 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
forms = module.exports = {} | |
forms.donate = [ | |
{name: "first_name", type: "text", level: null, req: true, label: "First Name:", active: true}, | |
{name: "last_name", type: "text", level: null, req: true, label: "Last Name:", active: true}, | |
{name: "email", type: "text", level: null, req: true, label: "Email:", active: true}, | |
{name: "message", type: "textarea", level: null, label: "Message:", active: false}, | |
{name: "cell_number", type: "text", level: null, label: "Cell Phone:", active: true}, | |
{name: "receive_text", type: "checkbox", level: null, label: "Would you like to receive text messages in the future?", active: true}, | |
{name: "donate", type: "button", level: null, text: "Donate <i class='icon-chevron-right'> </i>", active: true, class: "btn btn-primary disabled pull-right clearfix"}, | |
{name: "back", type: "button", level: null, text: "<i class='icon-chevron-left'> </i> Back", active: true, class: "btn btn-inverse disabled"} | |
] | |
# form middleware | |
forms.renderForm = (req, res, next) -> | |
req._form = Object.create | |
text: [] | |
textarea: [] | |
checkbox: [] | |
button: [] | |
for form in forms.donate | |
do (form) -> | |
if form["active"] is true | |
req._form.text.push form if form["type"] == "text" | |
req._form.textarea.push form if form["type"] == "textarea" | |
req._form.checkbox.push form if form["type"] == "checkbox" | |
req._form.button.push form if form["type"] == "button" | |
next() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment