- This was for sails/waterline, so I pushed as much as I could into the view layer so I wouldn't have to re-lift sails. Anything in the controller or server required a server restart.
- This is also totally geared for Bootstrap/horizontal forms. However, it can handle any rendering, just change formDefaults.json
- The project was already using lodash (though underline might work as well), so I do use that for simplicity. You will need that to use this
- This also has the added benefit of allowing you to pass in default values for fields
- I was also integrating JQuery form validation (client-side), so I needed a client error message. So, the system can handle error_message (which it sends down for the first time), or error (from forms itself). It sends down the most relevant (error, if present, then error_message)
- You can also hide HTML tags by making the tag '@' (I tried '', but ended up needing something else)
- formDefaults.json: The template to use to render the form widget
- FormService.js: A custom rendering function to apply this template to a form
- userFormParams.json: An example form for a user
- UserController.js: A snipped of the edit controller to render the form
- edit.ejs: The view rendering the form
This was using Labelauty to style buttons.
"dueDaymap": {
"label": "Due Days:",
"classes": ["form-control", "labelauty-cb", "labelauty-days"],
"label_class": "col-sm-1",
"inner_class": "col-sm-11 labelauty-holder labelauty-holder labelauty-holder-dueDaymap",
"choices": {
"Su": "Sun",
"Mo": "Mon",
"Tu": "Tue",
"We": "Wed",
"Th": "Thu",
"Fr": "Fri",
"Sa": "Sat"
},
"value": ["Su","Mo","Tu","We","Th","Fr","Sa"],
"error_message": "Please select 1 day minimum",
"error_class": "dueDaymap-error alert alert-danger text-center"
},