A smart package for generating forms
I'm in the process of reworking most of this. Most of the demos seem fine but some are broken. Check back in a week-ish (12/06/14) -Mike
If you define a client-side form called bookForm
and a validator class called BookValidator
it will be used to validate the form before it's method
attribute is called. Check out the other examples to see how to have the validations run on both client-side and server-side
If you want to validate server-side after client-side validation passes you can instantiate the validator in your Meteor.methods
. For this to work your validator needs to be defined in a common script so the validator will be available both client and server-side. See the Auto server demo to see how the library can eliminate boilerplate validation code in your Meteor.methods
by running the validation code for you.
If you define your form and validator in a common script the form's method
will be wrapped in a validation filter so validations will be run automatically on both the client and server. The form will handle errors and display them on the form if something causes validation to pass on the client and fail on the server.
TODO
Form objects emit lifecycle events so it's easy to customize a form's behavior. Watch your browser's console to see the events being fired.
TODO
TODO
If you're using meteor-model-base your forms will generate away much of the boilerplate code you'd have to write otherwise. But don't worry, if you want more control over how the form is processed you can disable most of the magic. Just let me know if there's something you need to turn off and you can't find a setting for it and I'll add one (the included preset system will be helpful in creating your own defaults). Some nice things the forms will do with your models:
Things it will do in the future (maybe soon¿):
Meteor.method
stubs