Skip to content

Commit 22558b5

Browse files
committed
Version 5.7.0
1 parent 2b38464 commit 22558b5

File tree

6 files changed

+22
-7
lines changed

6 files changed

+22
-7
lines changed

.versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
aldeed:autoform@5.6.1
1+
aldeed:autoform@5.7.0
22
33
44
@@ -26,7 +26,7 @@ [email protected]
2626
2727
2828
29-
local-test:aldeed:autoform@5.6.1
29+
local-test:aldeed:autoform@5.7.0
3030
3131
3232

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ forms with automatic insert and update events, and automatic reactive validation
66

77
## Change Log
88

9+
### 5.7.0
10+
11+
Sticky validation improvements
12+
13+
- Add API outside of hooks for settings and removing sticky validation errors
14+
- Properly show sticky validation errors as soon as they are added
15+
- Optimizations to keyup validation
16+
917
### 5.6.1
1018

1119
Fix boolean-radios templates

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ var hooksObject = {
10691069

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

1072-
* `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.
1072+
* `this.addStickyValidationError(key, type, [value])`: Calls `AutoForm.addStickyValidationError` for the form
10731073
* `this.autoSaveChangedElement`: The input element that was changed to cause this form submission (if the submission was due to autosave)
10741074
* `this.collection`: The collection attached to the form (from `collection` attribute)
10751075
* `this.currentDoc`: The current document attached to the form (from `doc` attribute)
@@ -1078,7 +1078,7 @@ The following properties and functions are available in all submission hooks whe
10781078
* `this.formAttributes`: The object containing all the form attributes from the `autoForm` or `quickForm`
10791079
* `this.formId`: The form's `id` attribute (useful in a global hook)
10801080
* `this.insertDoc`: The gathered current form values, as a normal object
1081-
* `this.removeStickyValidationError(key)`: Call this to remove a sticky validation error you previously added to the current form instance.
1081+
* `this.removeStickyValidationError(key)`: Calls `AutoForm.removeStickyValidationError` for the form
10821082
* `this.resetForm()`: Call this if you need to reset the form
10831083
* `this.ss`: The SimpleSchema instance used for validating the form
10841084
* `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.
@@ -1379,6 +1379,13 @@ The `fieldset` has class "af-fieldGroup" and the `legend` has class "af-fieldGro
13791379

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

1382+
## Sticky Validation Errors
1383+
1384+
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.
1385+
1386+
- `AutoForm.addStickyValidationError(formId, key, type, [value])`
1387+
- `AutoForm.removeStickyValidationError(formId, key)
1388+
13821389
## Defining Custom Input Types
13831390

13841391
Making a custom input type (form widget) is easy.

autoform-api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ AutoForm.addStickyValidationError = function addStickyValidationError(formId, ke
11271127
validateField(key, formId, false, false);
11281128
};
11291129

1130-
AutoForm.removeStickyValidationErrors = function removeStickyValidationErrors(formId, key) {
1130+
AutoForm.removeStickyValidationError = function removeStickyValidationError(formId, key) {
11311131
var template = AutoForm.templateInstanceForForm(formId);
11321132
if (!template) return;
11331133

autoform-events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Template.autoForm.events({
136136
formId: formId,
137137
formTypeDefinition: ftd,
138138
removeStickyValidationError: function (key) {
139-
AutoForm.removeStickyValidationErrors(formId, key);
139+
AutoForm.removeStickyValidationError(formId, key);
140140
},
141141
resetForm: function () {
142142
AutoForm.resetForm(formId, template);

package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package.describe({
22
name: "aldeed:autoform",
33
summary: "Easily create forms with automatic insert and update, and automatic reactive validation.",
44
git: "https://github.com/aldeed/meteor-autoform.git",
5-
version: "5.6.1"
5+
version: "5.7.0"
66
});
77

88
Package.onUse(function(api) {

0 commit comments

Comments
 (0)