Skip to content

Latest commit

 

History

History
308 lines (143 loc) · 8.45 KB

api.md

File metadata and controls

308 lines (143 loc) · 8.45 KB

autoform Public API

Provides UI components that allow you to easily create forms with automatic insert and update events, and automatic reactive validation.

API documentation automatically generated by docmeteor.

autoform.addHooks(formIds, hooks)  Client

This method addHooks is defined in AutoForm

Arguments

Form id or array of form IDs to which these hooks apply. Specify null to add hooks that will run for every form.

  • hooks {Object}

Hooks to add, where supported names are "before", "after", "formToDoc", "docToForm", "onSubmit", "onSuccess", and "onError".

Returns {undefined}

Defines hooks to be used by one or more forms. Extends hooks lists if called multiple times for the same form.

AutoForm.addHooks = function autoFormAddHooks(formIds, hooks, replace) { ... autoform-api.js:13

autoform.hooks(hooks)  Client

This method hooks is defined in AutoForm

Arguments

  • hooks {Object}

Returns {undefined}

Defines hooks by form id. Extends hooks lists if called multiple times for the same form.

AutoForm.hooks = function autoFormHooks(hooks, replace) { ... autoform-api.js:51

autoform.resetForm(formId, [template])  Client

This method resetForm is defined in AutoForm

Arguments

Looked up if not provided. Pass in for efficiency.

Returns {undefined}

Resets an autoform, including resetting validation errors. The same as clicking the reset button for an autoform.

AutoForm.resetForm = function autoFormResetForm(formId, template) { ... autoform-api.js:66

autoform.setDefaultTemplate(template)  Client

This method setDefaultTemplate is defined in AutoForm

Arguments

  • template {String}

AutoForm.setDefaultTemplate = function autoFormSetDefaultTemplate(template) { ... autoform-api.js:78

autoform.getDefaultTemplate()  Client

This method getDefaultTemplate is defined in AutoForm

Reactive.

AutoForm.getDefaultTemplate = function autoFormGetDefaultTemplate() { ... autoform-api.js:89

autoform.setDefaultTemplateForType(type, template)  Client

This method setDefaultTemplateForType is defined in AutoForm

Arguments

  • type {String}
  • template {String}

AutoForm.setDefaultTemplateForType = function autoFormSetDefaultTemplateForType(type, template) { ... autoform-api.js:100

autoform.getDefaultTemplateForType(type)  Client

This method getDefaultTemplateForType is defined in AutoForm

Arguments

  • type {String}

Returns {String} Template name

Reactive.

AutoForm.getDefaultTemplateForType = function autoFormGetDefaultTemplateForType(type) { ... autoform-api.js:119

autoform.getFormValues(formId)  Client

This method getFormValues is defined in AutoForm

Arguments

  • formId {String}

The id attribute of the autoForm you want current values for.

Returns {Object}

Returns an object representing the current values of all schema-based fields in the form. The returned object contains two properties, "insertDoc" and "updateDoc", which represent the field values as a normal object and as a MongoDB modifier, respectively.

AutoForm.getFormValues = function autoFormGetFormValues(formId) { ... autoform-api.js:137

autoform.getFieldValue(formId, fieldName)  Client

This method getFieldValue is defined in AutoForm

Arguments

  • formId {String}

The id attribute of the autoForm you want current values for.

  • fieldName {String}

The name of the field for which you want the current value.

Returns {Any}

Returns the value of the field (the value that would be used if the form were submitted right now). This is a reactive method that will rerun whenever the current value of the requested field changes.

AutoForm.getFieldValue = function autoFormGetFieldValue(formId, fieldName) { ... autoform-api.js:159

autoform.inputValueHandlers(handlers)  Client

This method inputValueHandlers is defined in AutoForm

Arguments

  • handlers {Object}

An object defining one or more selectors with corresponding handler function.

Returns {undefined}

Use this method to add custom input value handlers, which will be checked before the built-in handlers.

AutoForm.inputValueHandlers = function afInputValueHandlers(handlers) { ... autoform-api.js:175

autoform.validateField(formId, fieldName, [skipEmpty])  Client

This method validateField is defined in AutoForm

Arguments

  • formId {String}

The id attribute of the autoForm you want to validate.

  • fieldName {String}

The name of the field within the autoForm you want to validate.

  • skipEmpty {Boolean} (Optional, Default = false)

Set to true to skip validation if the field has no value. Useful for preventing required errors in form fields that the user has not yet filled out.

Returns {Boolean} Is it valid?

In addition to returning a boolean that indicates whether the field is currently valid, this method causes the reactive validation messages to appear.

AutoForm.validateField = function autoFormValidateField(formId, fieldName, skipEmpty) { ... autoform-api.js:190

autoform.validateForm(formId)  Client

This method validateForm is defined in AutoForm

Arguments

  • formId {String}

The id attribute of the autoForm you want to validate.

Returns {Boolean} Is it valid?

In addition to returning a boolean that indicates whether the form is currently valid, this method causes the reactive validation messages to appear.

AutoForm.validateForm = function autoFormValidateForm(formId) { ... autoform-api.js:208

autoform.getValidationContext(formId)  Client

This method getValidationContext is defined in AutoForm

Arguments

  • formId {String}

The id attribute of the autoForm for which you want the validation context

Returns {SimpleSchemaValidationContext} The SimpleSchema validation context object.

Use this method to get the validation context, which can be used to check the current invalid fields, manually invalidate fields, etc.

AutoForm.getValidationContext = function autoFormGetValidationContext(formId) { ... autoform-api.js:241

autoform.find()  Client

This method find is defined in AutoForm

Returns {Object} The data context for the closest autoform.

Call this method from a UI helper to get the data context for the closest autoform.

AutoForm.find = function autoFormFind(type) { ... autoform-api.js:256

autoform.debug()  Client

This method debug is defined in AutoForm

Call this method in client code while developing to turn on extra logging.

AutoForm.debug = function autoFormDebug() { ... autoform-api.js:273