Skip to content

Commit

Permalink
Version 5.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aldeed committed Oct 11, 2015
1 parent 2b38464 commit 22558b5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
aldeed:autoform@5.6.1
aldeed:autoform@5.7.0
aldeed:simple-schema@1.1.0
babel-compiler@5.8.24_1
babel-runtime@0.1.4
Expand Down Expand Up @@ -26,7 +26,7 @@ htmljs@1.0.5
id-map@1.0.4
jquery@1.11.4
livedata@1.0.15
local-test:aldeed:autoform@5.6.1
local-test:aldeed:autoform@5.7.0
logging@1.0.8
meteor@1.1.9
minifiers@1.1.7
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ forms with automatic insert and update events, and automatic reactive validation

## Change Log

### 5.7.0

Sticky validation improvements

- Add API outside of hooks for settings and removing sticky validation errors
- Properly show sticky validation errors as soon as they are added
- Optimizations to keyup validation

### 5.6.1

Fix boolean-radios templates
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ var hooksObject = {

The following properties and functions are available in all submission hooks when they are called. This does not include formToDoc, formToModifier, or docToForm.

* `this.addStickyValidationError(key, type, [value])`: Call this to add a custom validation error that will not be overridden by subsequent revalidations on the client. This can be useful if you need to show a form error based on errors coming back from the server, and you don't want it to disappear when fields are revalidated on the client on blur, keyup, etc. The sticky error will go away when the form is reset (such as after a successful submission), when the form instance is destroyed, or when you call `this.removeStickyValidationError(key)` in any hook.
* `this.addStickyValidationError(key, type, [value])`: Calls `AutoForm.addStickyValidationError` for the form
* `this.autoSaveChangedElement`: The input element that was changed to cause this form submission (if the submission was due to autosave)
* `this.collection`: The collection attached to the form (from `collection` attribute)
* `this.currentDoc`: The current document attached to the form (from `doc` attribute)
Expand All @@ -1078,7 +1078,7 @@ The following properties and functions are available in all submission hooks whe
* `this.formAttributes`: The object containing all the form attributes from the `autoForm` or `quickForm`
* `this.formId`: The form's `id` attribute (useful in a global hook)
* `this.insertDoc`: The gathered current form values, as a normal object
* `this.removeStickyValidationError(key)`: Call this to remove a sticky validation error you previously added to the current form instance.
* `this.removeStickyValidationError(key)`: Calls `AutoForm.removeStickyValidationError` for the form
* `this.resetForm()`: Call this if you need to reset the form
* `this.ss`: The SimpleSchema instance used for validating the form
* `this.ssIsOverride`: This is `true` if `this.ss` is an override schema, meaning it's coming from a `schema` attribute on the `autoForm` or `quickForm`, but there is also a `collection` attribute pointing to a collection that has its own schema attached.
Expand Down Expand Up @@ -1379,6 +1379,13 @@ The `fieldset` has class "af-fieldGroup" and the `legend` has class "af-fieldGro

The [Telescope](https://telescope.readme.io/docs) app makes use of this feature. Thanks to **@SachaG** for contributing it.

## Sticky Validation Errors

Every time AutoForm revalidates your form, it overwrites the list of invalid fields for that form. This means that adding your own errors to the form validation context (using the SimpleSchema API) will not always work because your custom errors will disappear upon first revalidation. To solve this, you can add sticky errors for a form. Sticky errors do not go away unless you reset the form, the form instance is destroyed, or you manually remove them.

- `AutoForm.addStickyValidationError(formId, key, type, [value])`
- `AutoForm.removeStickyValidationError(formId, key)

## Defining Custom Input Types

Making a custom input type (form widget) is easy.
Expand Down
2 changes: 1 addition & 1 deletion autoform-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ AutoForm.addStickyValidationError = function addStickyValidationError(formId, ke
validateField(key, formId, false, false);
};

AutoForm.removeStickyValidationErrors = function removeStickyValidationErrors(formId, key) {
AutoForm.removeStickyValidationError = function removeStickyValidationError(formId, key) {
var template = AutoForm.templateInstanceForForm(formId);
if (!template) return;

Expand Down
2 changes: 1 addition & 1 deletion autoform-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Template.autoForm.events({
formId: formId,
formTypeDefinition: ftd,
removeStickyValidationError: function (key) {
AutoForm.removeStickyValidationErrors(formId, key);
AutoForm.removeStickyValidationError(formId, key);
},
resetForm: function () {
AutoForm.resetForm(formId, template);
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package.describe({
name: "aldeed:autoform",
summary: "Easily create forms with automatic insert and update, and automatic reactive validation.",
git: "https://github.com/aldeed/meteor-autoform.git",
version: "5.6.1"
version: "5.7.0"
});

Package.onUse(function(api) {
Expand Down

0 comments on commit 22558b5

Please sign in to comment.