jonjamz / blaze-forms

Dead easy reactive forms with validation (Meteor).
https://atmospherejs.com/templates/forms
MIT License
113 stars 11 forks source link

Allow for custom messages in `success` or `failed` callbacks #50

Closed jonjamz closed 9 years ago

jonjamz commented 9 years ago

Useful if you want to relay information about the inserted data, for example "added 5 documents".

satyavh commented 9 years ago

I totally agree. It's a must have if you want to reuse form blocks and communicate in context. For example, a password form might want to say "your password is changed" and a contact form "contact has been updated". Now you have to make 2 form blocks for that, while it could be something like this:

ReactiveForms.createFormBlock
  template: 'formBlock'
  submitType: 'normal'  
  successMessage: 'Your password has changed'
  failedMessage: 'Oops, something went wrong'
  invalidMessage: 'There was a problem'
  loadingMessage: 'loading...'

This package is awesome in terms of reactive forms, incl attaching to simpleSchema. I totally get the idea. But the flexibility and re-usability of form blocks / elements only works for basic usecases. This package needs more API calls to be as reusable as it suggest , it should not try solve everything through html and helpers.

jonjamz commented 9 years ago

I was actually thinking of putting the functionality in the action function, like this:

callbacks.success('Added ' + num + ' new members to your group');
jonjamz commented 9 years ago

You can now pass messages into success and failed callbacks in your action function. Please see the docs for {{successMessage}} and {{failedMessage}} here:

https://github.com/meteortemplates/forms#form-block-template-helpers

The example Form Block above that section shows them in use.