You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1069,7 +1069,7 @@ var hooksObject = {
1069
1069
1070
1070
The following properties and functions are available in all submission hooks when they are called. This does not include formToDoc, formToModifier, or docToForm.
1071
1071
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
1073
1073
*`this.autoSaveChangedElement`: The input element that was changed to cause this form submission (if the submission was due to autosave)
1074
1074
*`this.collection`: The collection attached to the form (from `collection` attribute)
1075
1075
*`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
1078
1078
*`this.formAttributes`: The object containing all the form attributes from the `autoForm` or `quickForm`
1079
1079
*`this.formId`: The form's `id` attribute (useful in a global hook)
1080
1080
*`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
1082
1082
*`this.resetForm()`: Call this if you need to reset the form
1083
1083
*`this.ss`: The SimpleSchema instance used for validating the form
1084
1084
*`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
1379
1379
1380
1380
The [Telescope](https://telescope.readme.io/docs) app makes use of this feature. Thanks to **@SachaG** for contributing it.
1381
1381
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.
0 commit comments