API documentation automatically generated by docmeteor.
File: "utility.js" Where: {client}
global Utility:true, AutoForm, moment *
This property is private Used to validate time strings. This reg ex actually allows a few invalid hours/minutes/seconds, but we can catch that when parsing.
const timeStringRegExp = /^[0-2][0-9]:[0-5][0-9](:[0-5][0-9](\.[0-9]{ ...
utility.js:12
This method is private
This method cleanNulls is defined in Utility
Arguments
- doc {Object}
Source object
- isArray {Boolean}
- keepEmptyStrings {Boolean}
Returns {Object}
Returns an object in which all properties with null, undefined, or empty string values have been removed, recursively.
cleanNulls: function cleanNulls(doc, isArray, keepEmptyStrings) { ...
utility.js:37
This method is private
This method reportNulls is defined in Utility
Arguments
- flatDoc {Object}
An object with no properties that are also objects.
- keepEmptyStrings {Boolean}
Returns {Object} An object in which the keys represent the keys in the
original object that were null, undefined, or empty strings, and the value of each key is "".
reportNulls: function reportNulls(flatDoc, keepEmptyStrings) { ...
utility.js:74
This method is private
This method docToModifier is defined in Utility
Arguments
- doc {Object}
An object to be converted into a MongoDB modifier
- options {Object} (Optional)
Options
* __keepEmptyStrings__ *{Boolean}* (Optional)
Pass `true` to keep empty strings in the $set. Otherwise $unset them.
* __keepArrays__ *{Boolean}* (Optional)
Pass `true` to $set entire arrays. Otherwise the modifier will $set individual array items.
Returns {Object} A MongoDB modifier.
Converts an object into a modifier by flattening it, putting keys with
null, undefined, and empty string values into modifier.$unset
, and
putting the rest of the keys into modifier.$set
.
docToModifier: function docToModifier(doc, options) { ...
utility.js:113
This method is private
This method getSelectValues is defined in Utility
Arguments
- select {Element}
DOM Element from which to get current values
Returns {string[]}
Gets a string array of all the selected values in a given select
DOM element.
getSelectValues: function getSelectValues(select) { ...
utility.js:149
This method is private
This method lookup is defined in Utility
Arguments
- obj {Any}
Returns {Any}
If obj
is a string, returns the value of the property with that
name on the window
object. Otherwise returns obj
.
lookup: function lookup(obj) { ...
utility.js:200
This method is private
This method getFieldDefinition is defined in Utility
Arguments
- ss {SimpleSchema}
- name {String}
Returns {Object} Schema definitions object
Returns the schema definitions object from a SimpleSchema instance, grabbing the first type definition out of potentially multiple.
getFieldDefinition(ss, name) { ...
utility.js:223
This method is private
This method objAffectsKey is defined in Utility
Arguments
- {Object} {any}
obj
- {String} {any}
key
Returns {Boolean}
TODO
* should make this a static method in MongoObject
objAffectsKey: function objAffectsKey(obj, key) { ...
utility.js:240
This method is private
This method expandObj is defined in Utility
Arguments
- {Object} {any}
doc
Returns {Object}
Takes a flat object and returns an expanded version of it.
expandObj: function expandObj(doc) { ...
utility.js:252
This method is private
This method compactArrays is defined in Utility
Arguments
- {Object} {any}
obj
Returns {undefined}
Edits the object by reference, compacting any arrays at any level recursively.
compactArrays: function compactArrays(obj) { ...
utility.js:298
This method is private
This method bubbleEmpty is defined in Utility
Arguments
- {Object} {any}
obj
- keepEmptyStrings {String}
Returns {undefined}
Edits the object by reference.
bubbleEmpty: function bubbleEmpty(obj, keepEmptyStrings) { ...
utility.js:320
This method is private
This method isNullUndefinedOrEmptyString is defined in Utility
Arguments
- {Any} {any}
val
Returns {Boolean}
Returns true
if the value is null, undefined, or an empty string
isNullUndefinedOrEmptyString: function isNullUndefinedOrEmptyString(val) { ...
utility.js:354
This method is private
This method isValidDateString is defined in Utility
Arguments
- {String} {any}
dateString
Returns {Boolean}
Returns true
if dateString is a "valid date string"
isValidDateString: function isValidDateString(dateString) { ...
utility.js:369
This method is private
This method isValidTimeString is defined in Utility
Arguments
- {String} {any}
timeString
Returns {Boolean}
Returns true
if timeString is a "valid time string"
isValidTimeString: function isValidTimeString(timeString) { ...
utility.js:381
This method is private
Arguments
- {String} {any}
dateString
Returns {Boolean}
Returns true if dateString is a "valid normalized forced-UTC global date and time string"
isValidNormalizedForcedUtcGlobalDateAndTimeString: function isValidNormalizedForcedUtcGlobalDateAndTimeString(
utility.js:396
This method is private
Arguments
- {String} {any}
dtString
Returns {Boolean}
Returns true if dtString is a "valid normalized local date and time string"
isValidNormalizedLocalDateAndTimeString: function isValidNormalizedLocalDateAndTimeString(
utility.js:422
This method is private
This method getComponentContext is defined in Utility
Arguments
- {Object} {any}
context A context (this
) object
- name {String}
The name of the helper or component we're calling from.
Returns {Object|undefined} Normalized context object
Returns an object with atts
and defs
properties, normalized from whatever object is passed in.
This helps deal with the fact that we have to pass the ancestor autoform's context to different
helpers and components in different ways, but in all cases we want to get access to it and throw
an error if we can't find an autoform context.
getComponentContext: function autoFormGetComponentContext(context, name) { ...
utility.js:450
This method is private
This method stringToArray is defined in Utility
Arguments
- s {String|Array}
A variable that might be a string or an array.
- errorMessage {String}
Error message to use if it's not a string or an array.
Returns {Array} The array, building it from a comma-delimited string if necessary.
stringToArray: function stringToArray(s, errorMessage) { ...
utility.js:507
This method is private
This method addClass is defined in Utility
Arguments
- atts {Object}
An object that might have a "class" property
- klass {String}
The class string to add
Returns {Object} The object with klass added to the "class" property, creating the property if necessary
addClass: function addClass(atts, klass) { ...
utility.js:523
This method is private
This method getFormTypeDef is defined in Utility
Arguments
- formType {String}
The form type
Returns {Object} The definition. Throws an error if type hasn't been defined.
getFormTypeDef: function getFormTypeDef(formType) { ...
utility.js:537
Tests whether "obj" is an Object as opposed to
something that inherits from Object
Arguments
- obj {any}
Returns {Boolean}
const isBasicObject = function (obj) { ...
utility.js:580
File: "form-preserve.js" Where: {client}
This method is private
Arguments
- migrationName {String}
Internal helper object to preserve form inputs across Hot Code Push and across "pages" navigation if the option is enabled.
export const FormPreserve = function formPreserveConstructor(migrationName) { ...
form-preserve.js:9
File: "autoform-formdata.js" Where: {client}
Tracks form data with reactivity. This is similar to
ReactiveDict, but we need to store typed objects and
keep their type upon retrieval.
export const FormData = function FormData() { ...
autoform-formdata.js:7
Initializes tracking for a given form, if not already done.
This method initForm is defined in prototype
of FormData
Arguments
- formId {String}
The form's id
attribute
FormData.prototype.initForm = function (formId) { ...
autoform-formdata.js:16
Initializes tracking for a given form, if not already done.
This method sourceDoc is defined in prototype
of FormData
Arguments
- formId {String}
The form's id
attribute
FormData.prototype.sourceDoc = function (formId, sourceDoc) { ...
autoform-formdata.js:42
Gets or sets a source doc for the given form. Reactive.
This method sourceDoc is defined in prototype
of FormData
Arguments
- ____ {any}
{String} formId The form's id
attribute
- ____ {any}
{MongoObject|null} sourceDoc The mDoc for the form or null
if no doc.
Returns {MongoObject|undefined} Returns the form's MongoObject if getting.
FormData.prototype.sourceDoc = function (formId, sourceDoc) { ...
autoform-formdata.js:42
File: "autoform-arrays.js" Where: {client}
Track arrays; this allows us to add/remove fields or groups of fields for an array
but still easily respect minCount and maxCount, and properly add/remove the same
items from the database once the form is submitted.
export const ArrayTracker = function afArrayTracker() { ...
autoform-arrays.js:11
File: "autoform-helpers.js" Where: {client}
Template helper to get the current error message from schema.
@name afFieldMessage
Arguments
- options {Object}
Returns {}*
export const autoFormFieldMessage = function autoFormFieldMessage(options) { ...
autoform-helpers.js:23
@name afFieldIsInvalid
Arguments
- options {Object}
Returns {}*
export const autoFormFieldIsInvalid = function autoFormFieldIsInvalid(options) { ...
autoform-helpers.js:40
@name afArrayFieldHasMoreThanMinimum
Arguments
- options {Object}
Returns {boolean}
export const autoFormArrayFieldHasMoreThanMinimum = function autoFormArrayFieldHasMoreThanMinimum(
autoform-helpers.js:57
@name afArrayFieldHasLessThanMaximum
Arguments
- options {Object}
Returns {boolean}
export const autoFormArrayFieldHasLessThanMaximum = function autoFormArrayFieldHasLessThanMaximum(
autoform-helpers.js:91
@name autoFormFieldValueIs
Arguments
- options {Object}
Returns {boolean}
export const autoFormFieldValueIs = function autoFormFieldValueIs(options) { ...
autoform-helpers.js:125
@name autoFormFieldValue
Arguments
- options {Object}
Returns {Any}
export const autoFormFieldValue = function autoFormFieldValue(options) { ...
autoform-helpers.js:141
@name afArrayFieldIsFirstVisible
Returns {}*
export const autoFormArrayFieldIsFirstVisible = function autoFormArrayFieldIsFirstVisible() { ...
autoform-helpers.js:159
@name afArrayFieldIsLastVisible
Returns {}*
export const autoFormArrayFieldIsLastVisible = function autoFormArrayFieldIsLastVisible() { ...
autoform-helpers.js:179
@name afFieldLabelText
Arguments
- options {Object}
Returns {Object}
export const autoFormFieldLabelText = function autoFormFieldLabelText(options) { ...
autoform-helpers.js:218
@name afFieldNames
Arguments
- options {Object}
Returns *{{name: }[]}
export const autoFormFieldNames = function autoFormFieldNames(options) { ...
autoform-helpers.js:232
@name afSelectOptionAtts
Returns {}*
export const afSelectOptionAtts = function afSelectOptionAtts() { ...
autoform-helpers.js:411
File: "autoform-validation.js" Where: {client}
global AutoForm, validateField:true *
Validates a field on a given form by id.
This method is private
Arguments
- {String} {key}
a specific schema key to validate
- {String} {formId}
the id the form the key belongs to
- {Boolean} {skipEmpty}
allows to skip validation if the key has no value
- onlyIfAlreadyInvalid {Boolean}
Returns {}*
const _validateField = function _validateField(
autoform-validation.js:15
Throttle field validation to occur at most every 300ms, with leading and trailing calls.
File: "autoform-inputs.js" Where: {client}
Creates a flat document that contains all field values as key/value pair, where key = fieldname and value = the
field's current input value.
Arguments
- {jQueryObjectList} {fields}
A current jQuery-Object list, that allows to iterate over each element.
- {SimpleSchema} {ss}
The current SimpleSchema instance for the form, related to the fields.
Returns {Object} The document Object with key/value-paired fields.
export const getFlatDocOfFieldValues = function getFlatDocOfFieldValues(
autoform-inputs.js:11
Gets the value that should be shown/selected in the input. Returns
a string, a boolean, or an array of strings. The value used,
in order of preference, is one of:
- The `value` attribute provided
- The value that is set in the `doc` provided on the containing autoForm
- The `defaultValue` from the schema
Arguments
- {Object} {atts}
The current field attributes
- {*} {value}
The current value of the field, can be anything
- {Object} {mDoc}
The current doc, wrapped by MongoObject
- {*} {schemaDefaultValue}
The defaultValue as defined in the schema
- {*} {fieldDefaultValue}
The defaultValue as defined on the field level
- {Object} {typeDefs}
The type definitions that are used when an input is registered (valueIn, valueIsArray etc.)
Returns {}* The (maybe transformed) input value.
export const getInputValue = function getInputValue(
autoform-inputs.js:47
Builds the data context that the input component will have. Not reactive.
Arguments
- {Object} {defs}
The field definitions
- {Object} {hash}
The field attributes
- {*} {value}
The value of the input, can be many types
- {String} {label}
The label to be displayed
- {String} {formType}
the type of the form (insert, update, normal, method etc.)
@example const iData = getInputData(defs, atts, value, ss.label(c.atts.name), form.type);
export const getInputData = function getInputData(
autoform-inputs.js:111
Set up the context. This is the object that becomes `this` in the
input type template.
const inputTypeContext = { ...
autoform-inputs.js:182
Merge data property from the field schema with the context.
We do not want these turned into HTML attributes.
if (hash.data) Object.assign(inputTypeContext, hash.data);
autoform-inputs.js:196
This property is private
Arguments
- {Function} {fn}
The markChanged function to be passed
- {Number} {limit}
The throttle limit in ms
Returns {Function} The throttled markChanged function
function markChangedThrottle(fn, limit) { ...
autoform-inputs.js:214
This method is private
Arguments
- template {Template}
- fieldName {String}
ensures, that the ancestor (something) is marked changed, too.
const markChangedAncestors = (template, fieldName) => { ...
autoform-inputs.js:230
This method is private
Arguments
- template {Template}
Returns {|{}|boolean}* truthy/falsy value, based on all checked properties
const isRendered = (template) =>
autoform-inputs.js:246
This method is private
Arguments
- template {Template}
- fieldName {String}
const doMarkChanged = (template, fieldName) => { ...
autoform-inputs.js:257
Marks a field as changed and updates the Treacker.Dependdency as changed. Reactivity compatible.
Arguments
- {Template} {template}
The current form template
- {String} {fieldName}
The name of the current field
- {*} {fieldValue}
The current field value
export const markChanged = markChangedThrottle(function _markChanged(
autoform-inputs.js:274
Creates a formValues entry on the template, in case it does not exist yet and updates the given
field by fieldName as changed (if ok for update). Reactivity compatible.
Arguments
- {Template} {template}
The current form template
- {String} {fieldName}
The name of the current field
- {*} {fieldValue}
The current field value
export const updateTrackedFieldValue = function updateTrackedFieldValue(
autoform-inputs.js:301
Calls {updateTrackedFieldValue} on all fields it can find in template.formValues. Reactivity compatible.
Arguments
- {Template} {template}
The current form template
export const updateAllTrackedFieldValues = function updateAllTrackedFieldValues(
autoform-inputs.js:321
File: "autoform-api.js" Where: {client}
This property Utility is defined in AutoForm
AutoForm.Utility = Utility;
autoform-api.js:21
This method addHooks is defined in AutoForm
Arguments
- formIds {String[]|String|null}
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".
- replace {Boolean}
Replaces all existing hooks with the ones in {hooks}, if true
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:34
This method hooks is defined in AutoForm
Arguments
- hooks {Object}
Hooks to add, where supported names are "before", "after", "formToDoc", "docToForm", "onSubmit", "onSuccess", and "onError".
- replace {Boolean}
Replaces all existing hooks with the ones in {hooks}, if true
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:62
This property _hooks is defined in AutoForm
Hooks list to aid automated testing
Object.defineProperty(AutoForm,
autoform-api.js:74
This property _globalHooks is defined in AutoForm
Global hooks list to aid automated testing
Object.defineProperty(AutoForm,
autoform-api.js:87
This method _forceResetFormValues is defined in AutoForm
Arguments
- formId {String}
Returns {undefined}
Forces an AutoForm"s values to properly update. See https:
AutoForm._forceResetFormValues = function autoFormForceResetFormValues(formId) { ...
autoform-api.js:102
This method resetForm is defined in AutoForm
Arguments
- formId {String}
- template {TemplateInstance} (Optional)
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:121
This method setDefaultTemplate is defined in AutoForm
Arguments
- template {String}
AutoForm.setDefaultTemplate = function autoFormSetDefaultTemplate(template) { ...
autoform-api.js:132
This method getDefaultTemplate is defined in AutoForm
Reactive.
AutoForm.getDefaultTemplate = function autoFormGetDefaultTemplate() { ...
autoform-api.js:143
This method setDefaultTemplateForType is defined in AutoForm
Arguments
- type {String}
- template {String}
AutoForm.setDefaultTemplateForType = function autoFormSetDefaultTemplateForType(
autoform-api.js:154
This method getDefaultTemplateForType is defined in AutoForm
Arguments
- type {String}
Returns {String} Template name
Reactive.
AutoForm.getDefaultTemplateForType = function autoFormGetDefaultTemplateForType(
autoform-api.js:178
This property is private
const toTypeTemplate = (type, template) => `${ ...
autoform-api.js:191
This method getTemplateName is defined in AutoForm
Arguments
- templateType {String}
- templateName {String}
- fieldName {String} (Optional)
- skipExistsCheck {Boolean} (Optional)
Pass true
to return a template name even if that template hasn"t been defined.
Returns {String} Template name
Returns the full template name. In the simplest scenario, this is templateType_templateName as passed in. However, if templateName is not provided, it is looked up in the following manner:
- autoform..template from the schema (field+type override for all forms)
- autoform.template from the schema (field override for all forms)
- template- attribute on an ancestor component within the same form (form+type for all fields)
- template attribute on an ancestor component within the same form (form specificity for all types and fields)
- Default template for component type, as set by AutoForm.setDefaultTemplateForType
- Default template, as set by AutoForm.setDefaultTemplate.
- Built-in default template, currently bootstrap-3.
AutoForm.getTemplateName = function autoFormGetTemplateName(
autoform-api.js:214
This method getFormValues is defined in AutoForm
Arguments
- formId {String}
The id
attribute of the autoForm
you want current values for.
- template {Template} (Optional)
The template instance, if already known, as a performance optimization.
- ss {SimpleSchema} (Optional)
The SimpleSchema instance, if already known, as a performance optimization.
- getModifier {Boolean} (Optional)
Set to true
to return a modifier object or false
to return a normal object. For backwards compatibility, and object containing both is returned if this is undefined.
- clean {Boolean} (Optional)
- disabled {Boolean} (Optional)
Returns {Object|null}
Returns an object representing the current values of all schema-based fields in the form.
The returned object is either a normal object or a MongoDB modifier, based on the getModifier
argument. Return value may be null
if the form is not currently rendered on screen.
AutoForm.getFormValues = function autoFormGetFormValues(
autoform-api.js:322
This method resetValueCache is defined in AutoForm
Arguments
- formId {String} (Optional)
The id
attribute of the autoForm
you want current values for. Default is the closest form from the current context.
- fieldName {String} (Optional)
The field name
you want to reset the cache of.
Returns {Any|undefined}
Reset the cache and mark all fields as changed
AutoForm.resetValueCache = function autoFormResetValueCache(formId, fieldName) { ...
autoform-api.js:490
This method getFieldValue is defined in AutoForm
Arguments
- fieldName {String}
The name of the field for which you want the current value.
- formId {String} (Optional)
The id
attribute of the autoForm
you want current values for. Default is the closest form from the current context.
- clean {Boolean} (Optional)
Indicates if the method should clean the values or not. Default is true.
Returns {Any|undefined}
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. Return value will be undefined if the field is not currently rendered.
AutoForm.getFieldValue = function autoFormGetFieldValue(
autoform-api.js:540
This method setFieldValue is defined in AutoForm
Arguments
- fieldName {String}
The name of the field for which you want to set the current value.
- value {Any}
Value of the field
- formId {String} (Optional)
The id
attribute of the autoForm
you want current values for. Default is the closest form from the current context.
Returns {Any|undefined}
Sets the value for a field, resets the cache and emits changed events (reactive).
AutoForm.setFieldValue = function autoFormSetFieldValue(
autoform-api.js:599
This method setFormValues is defined in AutoForm
Arguments
- value {Any}
Value of the form
- formId {String} (Optional)
The id
attribute of the autoForm
you want current values for. Default is the closest form from the current context.
Returns {Any|undefined}
Sets the value for a field, resets the cache and emits changed events.
AutoForm.setFormValues = function autoFormSetFormValues(value, formId) { ...
autoform-api.js:632
This method getInputTypeTemplateNameForElement is defined in AutoForm
Arguments
- element {DOMElement}
The input DOM element, generated by an autoform input control
Returns {String}
Returns the name of the template used to render the element.
AutoForm.getInputTypeTemplateNameForElement = function autoFormGetInputTypeTemplateNameForElement(
autoform-api.js:644
This method getInputValue is defined in AutoForm
Arguments
- element {DOMElement} (Optional)
The input DOM element, generated by an autoform input control, which must have a data-schema-key
attribute set to the correct schema key name.
- ss {SimpleSchema} (Optional)
Provide the SimpleSchema instance if you already have it.
Returns {Any}
Returns the value of the field (the value that would be used if the form were submitted right now).
Unlike AutoForm.getFieldValue
, this function is not reactive.
AutoForm.getInputValue = function autoFormGetInputValue(element, ss) { ...
autoform-api.js:676
This method addInputType is defined in AutoForm
Arguments
- name {String}
The type string that this definition is for.
- definition {Object}
Defines how the input type should be rendered.
* __componentName__ *{String}*
The component name. A template with the name <componentName>_bootstrap3, and potentially others, must be defined.
Returns {undefined}
Use this method to add custom input components.
AutoForm.addInputType = function afAddInputType(name, definition) { ...
autoform-api.js:751
This method addFormType is defined in AutoForm
Arguments
- name {String}
The type string that this definition is for.
- definition {Object}
Defines how the submit type should work
* __adjustInputContext__ *{Function}* (Optional)
A function that accepts a single argument, which is the context with which an input template in the form will be called, potentially changes the context object, and then returns it. For example, the "readonly" and "disabled" form types use this function to add the "readonly" or "disabled" attribute, respectively, to every input within the form.
* __adjustSchema__ *{Function}* (Optional)
A function that accepts a single argument, which is the form schema, and potentially uses that to return a different schema to use instead. For example, the "update-pushArray" form type uses this function to build and return a schema that is limited by the `scope` attribute on the form. When this function is called, `this` contains useful information about the form.
* __hideArrayItemButtons__ *{Boolean}* (Optional)
Set to `true` if this form type should not show buttons for adding and removing items in an array field. The "disabled" and "readonly" form types do this.
* __onSubmit__ *{Function}*
A function that does whatever should happen upon submission of this form type. When this function is called, `this` contains useful information about the form. At a minimum, you probably want to call `this.event.preventDefault()` to prevent the browser from submitting the form. Your submission logic may want to rely on additional custom form attributes, which will be available in `this.formAttributes`. If you do any additional validation and it fails, you should call `this.failedValidation()`. When your logic is done, you should call `this.result(error, result)`. If you want to end the submission process without providing a result, call `this.endSubmission()`. If you don"t call `this.result()` or `this.endSubmission()`, `endSubmit` hooks won"t be called, so for example the submit button might remain disabled. `onError` hooks will be called only if you pass an error to `this.result()`. `onSuccess` hooks will be called only if you do not pass an error to `this.result()`.
* __shouldPrevalidate__ *{Function}* (Optional)
A function that returns `true` if validation against the form schema should happen before the `onSubmit` function is called, or `false` if not. When this function is called, `this` contains useful information about the form. If this function is not provided for a form type, the default is `true`.
* __validateForm__ *{Function}*
A function that validates the form and returns `true` if valid or `false` if not. This can happen during submission but also at other times. When this function is called, `this` contains useful information about the form and the validation options.
Returns {undefined}
Use this method to add custom form types.
AutoForm.addFormType = function afAddFormType(name, definition) { ...
autoform-api.js:772
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(
autoform-api.js:789
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:806
This method getValidationContext is defined in AutoForm
Arguments
- formId {String} (Optional)
The id
attribute of the autoForm
for which you want the validation context
Returns {SimpleSchema.ValidationContext} 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:846
This method findAttribute is defined in AutoForm
Arguments
- attrName {String}
Attribute name
Returns {Any|undefined} Searches for the given attribute, looking up the parent context tree until the closest autoform is reached.
Call this method from a UI helper. Might return undefined.
AutoForm.findAttribute = function autoFormFindAttribute(attrName) { ...
autoform-api.js:863
This method findAttributesWithPrefix is defined in AutoForm
Arguments
- prefix {String}
Attribute prefix
Returns {Object} An object containing all of the found attributes and their values, with the prefix removed from the keys.
Call this method from a UI helper. Searches for attributes that start with the given prefix, looking up the parent context tree until the closest autoform is reached.
AutoForm.findAttributesWithPrefix = function autoFormFindAttributesWithPrefix(
autoform-api.js:905
This method debug is defined in AutoForm
Call this method in client code while developing to turn on extra logging. You need to call it just one time, usually in top level client code.
AutoForm.debug = function autoFormDebug() { ...
autoform-api.js:953
This property arrayTracker is defined in AutoForm
AutoForm.arrayTracker = arrayTracker;
autoform-api.js:966
This method getInputType is defined in AutoForm
Arguments
- attributes {Object} (Optional)
The attributes provided to afFieldInput.
Returns {String}
The input type. Most are the same as the type
attributes for HTML input elements, but some are special strings that autoform interprets.
Call this method from a UI helper to get the type string for the input control.
AutoForm.getInputType = function getInputType(attributes) { ...
autoform-api.js:976
This method getSchemaForField is defined in AutoForm
Arguments
- name {String}
The field name attribute / schema key.
Returns {Object|undefined}
Call this method from a UI helper to get the field definitions based on the schema used by the closest containing autoForm.
AutoForm.getSchemaForField = function autoFormGetSchemaForField(name) { ...
autoform-api.js:1059
This method _getOptionsForField is defined in AutoForm
Arguments
- name {String}
The field name attribute / schema key.
Returns {Array(Object)|String|undefined}
Call this method from a UI helper to get the select options for the field. Might return the string "allowed".
AutoForm._getOptionsForField = function autoFormGetOptionsForField(name) { ...
autoform-api.js:1073
This method getLabelForField is defined in AutoForm
Arguments
- name {String}
The field name attribute / schema key.
Returns {Object}
Call this method from a UI helper to get the field definitions based on the schema used by the closest containing autoForm.
AutoForm.getLabelForField = function autoFormGetLabelForField(name) { ...
autoform-api.js:1105
This method templateInstanceForForm is defined in AutoForm
Arguments
- formId {String} (Optional)
The form"s id
attribute
Returns {TemplateInstance|undefined} The template instance.
Gets the template instance for the form with formId or the closest form to the current context.
AutoForm.templateInstanceForForm = function (formId) { ...
autoform-api.js:1117
This method viewForForm is defined in AutoForm
Arguments
- formId {String} (Optional)
The form"s id
attribute. Do not pass this if calling from within a form context.
Returns {Blaze.View|undefined}
The Blaze.View
instance for the autoForm.
Gets the Blaze.View
instance for the form with formId or the closest form to the current context.
AutoForm.viewForForm = function (formId) { ...
autoform-api.js:1132
This method getArrayCountFromDocForField is defined in AutoForm
Arguments
- formId {String}
The form"s id
attribute
- field {String}
The field name (schema key)
Returns {Number|undefined} Array count in the attached document.
Looks in the document attached to the form to see if the requested field exists and is an array. If so, returns the length (count) of the array. Otherwise returns undefined.
AutoForm.getArrayCountFromDocForField = function (formId, field) { ...
autoform-api.js:1169
This method parseData is defined in AutoForm
Arguments
- data {Object}
Current data context for the form, or an empty object. Usually this is used from a quickForm, since the autoForm won"t be rendered yet. Otherwise you should use AutoForm.getCurrentDataForForm if you can.
Returns {Object} Current data context for the form, or an empty object.
Parses and alters the current data context for a form. It will have default values added and a _resolvedSchema
property that has the schema the form should use.
AutoForm.parseData = function (data) { ...
autoform-api.js:1189
This method getCurrentDataForForm is defined in AutoForm
Arguments
- formId {String}
The form"s id
attribute
Returns {Object|undefined} Current data context for the form, or an empty object.
Returns the current data context for a form. You can call this without a formId from within a helper and the data for the nearest containing form will be returned.
AutoForm.getCurrentDataForForm = function (formId) { ...
autoform-api.js:1203
This method getCurrentDataPlusExtrasForForm is defined in AutoForm
Arguments
- ____ {any}
{String} [formId] The form"s id
attribute
Returns {Object} Current data context for the form, or an empty object.
Returns the current data context for a form plus some extra properties. You can call this without a formId from within a helper and the data for the nearest containing form will be returned.
AutoForm.getCurrentDataPlusExtrasForForm = function (formId) { ...
autoform-api.js:1223
This method getFormCollection is defined in AutoForm
Arguments
- formId {String}
The form"s id
attribute
Returns {Mongo.Collection|undefined} The Collection instance
Gets the collection for a form from the collection
attribute
AutoForm.getFormCollection = function (formId) { ...
autoform-api.js:1242
This method getFormSchema is defined in AutoForm
Arguments
- formId {String} (Optional)
The form"s id
attribute
- form {Object} (Optional)
Pass the form data context as an optimization or if the form is not yet rendered.
Returns {SimpleSchema|undefined} The SimpleSchema instance
Gets the schema for a form, from the schema
attribute if
provided, or from the schema attached to the Mongo.Collection
specified in the collection
attribute. The form must be
currently rendered.
AutoForm.getFormSchema = function (formId, form) { ...
autoform-api.js:1259
This method getFormId is defined in AutoForm
Returns {String}
The containing form"s id
attribute value
Call in a helper to get the containing form"s id
attribute. Reactive.
AutoForm.getFormId = function () { ...
autoform-api.js:1271
This method selectFirstInvalidField is defined in AutoForm
Arguments
- formId {String}
The id
attribute of the form
- ss {SimpleSchema}
The SimpleSchema instance that was used to create the form"s validation context.
Returns {undefined}
Selects the focus the first field (in DOM order) with an error.
AutoForm.selectFirstInvalidField = function selectFirstInvalidField(
autoform-api.js:1284
Adds validation errors to their respective inputs.
This method addStickyValidationError is defined in AutoForm
Arguments
- formId {String}
- key {String}
- type {String}
- value {String}
AutoForm.addStickyValidationError = function addStickyValidationError(
autoform-api.js:1316
Removes validation errors from their respective inputs.
This method removeStickyValidationError is defined in AutoForm
Arguments
- formId {String}
- key {String}
AutoForm.removeStickyValidationError = function removeStickyValidationError(
autoform-api.js:1340
This method _validateFormDoc is defined in AutoForm
Arguments
- doc {Object}
The document with the gathered form values to validate.
- isModifier {Boolean}
Is doc
actually a mongo modifier object?
- formId {String}
The form id
attribute
- ss {SimpleSchema}
The SimpleSchema instance against which to validate.
- form {Object}
The form context object
- key {String} (Optional)
Optionally, a specific schema key to validate.
Returns {Boolean} Is the form valid?
If creating a form type, you will often want to call this from the validateForm
function.
It provides the generic form validation logic that does not typically change between form types.
AutoForm._validateFormDoc = function validateFormDoc(
autoform-api.js:1369
Sets defaults for the form data context
This method is private
Returns {String} The data context with property defaults added.
setDefaults = function setDefaults(data) { ...
autoform-api.js:1451
File: "inputTypes/value-converters.js" Where: {client}
This method is private
Arguments
- {Date} {any}
date
Returns {String}
Returns a "valid date string" representing the local date.
dateToDateString: function dateToDateString(val) { ...
inputTypes/value-converters.js:47
This method is private
Arguments
- {Date} {any}
date
Returns {String}
Returns a "valid date string" representing the date converted to the UTC time zone.
dateToDateStringUTC: function dateToDateStringUTC(val) { ...
inputTypes/value-converters.js:58
This method is private
Arguments
- {Date} {any}
date
Returns {String}
Returns a "valid normalized forced-UTC global date and time string" representing the time converted to the UTC time zone and expressed as the shortest possible string for the given time (e.g. omitting the seconds component entirely if the given time is zero seconds past the minute).
http: http:
dateToNormalizedForcedUtcGlobalDateAndTimeString: function dateToNormalizedForcedUtcGlobalDateAndTimeString(val) { ...
inputTypes/value-converters.js:80
This method is private
This method dateToNormalizedLocalDateAndTimeString is defined in AutoForm.valueConverters
Arguments
- date {Date}
The Date object
- timezoneId {String} (Optional)
A valid timezoneId that moment-timezone understands, e.g., "America/Los_Angeles"
Returns {String}
Returns a "valid normalized local date and time string".
dateToNormalizedLocalDateAndTimeString: function dateToNormalizedLocalDateAndTimeString(date, timezoneId) { ...
inputTypes/value-converters.js:98
This method stringToNumber is defined in AutoForm.valueConverters
Arguments
- val {String}
A string or null or undefined.
Returns {Number|String} The string converted to a Number or the original value.
For strings, returns Number(val) unless the result is NaN. Otherwise returns val.
stringToNumber: function stringToNumber(val) { ...
inputTypes/value-converters.js:142
This method is private
This method stringToBoolean is defined in AutoForm.valueConverters
Arguments
- val {String}
A string or null or undefined.
Returns {Boolean|String} The string converted to a Boolean.
If the string is "true" or "1", returns true
. If the string is "false" or "0", returns false
. Otherwise returns the original string.
stringToBoolean: function stringToBoolean(val) { ...
inputTypes/value-converters.js:169
This method is private
This method stringToDate is defined in AutoForm.valueConverters
Arguments
- val {String}
A string or null or undefined.
Returns {Date|String} The string converted to a Date instance.
Returns new Date(val) as long as val is a string with at least one character. Otherwise returns the original string.
stringToDate: function stringToDate(val) { ...
inputTypes/value-converters.js:198
File: "autoform-events.js" Where: {client}
Returns `true` if the specified validation type should
be revalidated only when the form is already invalid.
Arguments
- validationType {String}
The validation type string.
function onlyIfAlreadyInvalid(validationType) { ...
autoform-events.js:70
Given an element, returns the schema key for it, using the
`data-schema-key` attribute on the element or on the closest
element that has one.
Arguments
- ____ {any}
{Element} element The DOM element
Returns {String|undefined} The schema key
function getKeyForElement(element) { ...
autoform-events.js:84