Skip to content

Latest commit

 

History

History
1864 lines (899 loc) · 48.2 KB

internal.api.md

File metadata and controls

1864 lines (899 loc) · 48.2 KB

Public and Private API

API documentation automatically generated by docmeteor.


File: "utility.js" Where: {client}


Utility.cleanNulls(doc)  Client

This method is private This method cleanNulls is defined in Utility

Arguments

  • doc {Object}

Source object

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:14

Utility.reportNulls(flatDoc)  Client

This method is private This method reportNulls is defined in Utility

Arguments

  • flatDoc {Object}

An object with no properties that are also objects.

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:43

Utility.docToModifier(doc, [options])  Client

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:75

Utility.getSelectValues(select)  Client

This method is private This method getSelectValues is defined in Utility

Arguments

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:102

Utility.lookup(obj)  Client

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:153

Utility.getDefs(ss, name)  Client

This method is private This method getDefs is defined in Utility

Arguments

Returns {Object} Schema definitions object

Returns the schema definitions object from a SimpleSchema instance. Equivalent to calling ss.schema(name) but handles throwing errors if name is not a string or is not a valid field name for this SimpleSchema instance.

getDefs: function getDefs(ss, name) { ... utility.js:176

Utility.objAffectsKey({Object}, {String})  Client

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:195

Utility.expandObj({Object})  Client

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:207

Utility.compactArrays({Object})  Client

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:244

Utility.bubbleEmpty({Object})  Client

This method is private This method bubbleEmpty is defined in Utility

Arguments

  • {Object} {any}

obj

Returns {undefined}

Edits the object by reference.

bubbleEmpty: function bubbleEmpty(obj, keepEmptyStrings) { ... utility.js:267

Utility.isNullUndefinedOrEmptyString({Any})  Client

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:296

Utility.isValidDateString({String})  Client

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:307

Utility.isValidTimeString({String})  Client

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:319

({String})  Client

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(dateString) { ... utility.js:337

({String})  Client

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(dtString) { ... utility.js:356

Utility.getComponentContext({Object}, name)  Client

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} 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:378

Utility.stringToArray(s, errorMessage)  Client

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:428

Utility.addClass(atts, klass)  Client

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:444

Utility.getFormTypeDef(formType)  Client

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:458

isBasicObject(obj)  Client

Tests whether "obj" is an Object as opposed to
something that inherits from Object

This method is private

Arguments

  • obj {any}

Returns {Boolean}

var isBasicObject = function(obj) { ... utility.js:493


File: "form-preserve.js" Where: {client}


new FormPreserve(migrationName)  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.

FormPreserve = function formPreserveConstructor(migrationName) { ... form-preserve.js:9


File: "autoform-formdata.js" Where: {client}


FormData {any}  Client

Tracks form data with reactivity. This is similar to
ReactiveDict, but we need to store typed objects and
keep their type upon retrieval.

FormData = function () { ... autoform-formdata.js:9

formdata.initForm(formId)  Client

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:18

formdata.sourceDoc(formId)  Client

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:44

formdata.sourceDoc(, )  Client

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:44


File: "autoform-helpers.js" Where: {client}


Template.registerHelper {any}  Client

afTemplateName
Deprecated. Don't use this. Eventually remove it.

This property registerHelper is defined in Template

Template.registerHelper( autoform-helpers.js:283


File: "autoform-inputs.js" Where: {client}


getInputValue {any}  Client

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

getInputValue = function getInputValue(atts, value, mDoc, schemaDefaultValue, fieldDefaultValue, typeDefs) { ... autoform-inputs.js:28

inputTypeContext {any}  Client

Set up the context. This is the object that becomes `this` in the
input type template.

This property is private

var inputTypeContext = { ... autoform-inputs.js:137

if {any}  Client

Merge data property from the field schema with the context.
We do not want these turned into HTML attributes.

if(hash.data){ ... autoform-inputs.js:152


File: "autoform-api.js" Where: {client}


AutoForm.Utility {any}  Client

This property Utility is defined in AutoForm

AutoForm.Utility = Utility; autoform-api.js:11

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:23

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._hooks {any}  Client

This property _hooks is defined in AutoForm

Hooks list to aid automated testing

AutoForm._hooks = Hooks.form; autoform-api.js:63

AutoForm._globalHooks {any}  Client

This property _globalHooks is defined in AutoForm

Global hooks list to aid automated testing

AutoForm._globalHooks = Hooks.global; autoform-api.js:71

AutoForm._forceResetFormValues(formId)  Client

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:82

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:100

AutoForm.setDefaultTemplate(template)  Client

This method setDefaultTemplate is defined in AutoForm

Arguments

  • template {String}

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

AutoForm.getDefaultTemplate()  Client

This method getDefaultTemplate is defined in AutoForm

Reactive.

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

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:133

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:152

AutoForm.getTemplateName(templateType, templateName, [fieldName], [skipExistsCheck])  Client

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:

  1. autoform..template from the schema (field+type override for all forms)
  2. autoform.template from the schema (field override for all forms)
  3. template- attribute on an ancestor component within the same form (form+type for all fields)
  4. template attribute on an ancestor component within the same form (form specificity for all types and fields)
  5. Default template for component type, as set by AutoForm.setDefaultTemplateForType
  6. Default template, as set by AutoForm.setDefaultTemplate.
  7. Built-in default template, currently bootstrap-3.

AutoForm.getTemplateName = function autoFormGetTemplateName(templateType, templateName, fieldName, skipExistsCheck) { ... autoform-api.js:181

AutoForm.getFormValues(formId, [template], [ss], [getModifier])  Client

This method getFormValues is defined in AutoForm

Arguments

  • formId {String}

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

The template instance, if already known, as a performance optimization.

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.

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(formId, template, ss, getModifier) { ... autoform-api.js:255

AutoForm.getFieldValue(fieldName, [formId])  Client

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.

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(fieldName, formId) { ... autoform-api.js:409

AutoForm.getInputTypeTemplateNameForElement(element)  Client

This method getInputTypeTemplateNameForElement is defined in AutoForm

Arguments

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(element) { ... autoform-api.js:444

AutoForm.getInputValue(element, [ss])  Client

This method getInputValue is defined in AutoForm

Arguments

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.

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:472

AutoForm.addInputType(name, definition)  Client

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:565

AutoForm.addFormType(name, definition)  Client

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:586

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:603

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:616

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:652

AutoForm.findAttribute(attrName)  Client

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:665

AutoForm.findAttributesWithPrefix(prefix)  Client

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(prefix) { ... autoform-api.js:706

AutoForm.debug()  Client

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:750

AutoForm.arrayTracker {any}  Client

This property arrayTracker is defined in AutoForm

AutoForm.arrayTracker = arrayTracker; autoform-api.js:764

AutoForm.getInputType(atts)  Client

This method getInputType is defined in AutoForm

Arguments

  • atts {Object}

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(atts) { ... autoform-api.js:774

AutoForm.getSchemaForField(name)  Client

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:863

AutoForm._getOptionsForField(name)  Client

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:877

AutoForm.getLabelForField(name)  Client

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:911

AutoForm.templateInstanceForForm([formId])  Client

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:930

AutoForm.viewForForm([formId])  Client

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:946

AutoForm.getArrayCountFromDocForField(formId, field)  Client

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:983

AutoForm.parseData(data)  Client

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:1003

AutoForm.getCurrentDataForForm(formId)  Client

This method getCurrentDataForForm is defined in AutoForm

Arguments

  • formId {String}

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. 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:1017

AutoForm.getCurrentDataPlusExtrasForForm()  Client

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:1039

AutoForm.getFormCollection(formId)  Client

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:1059

AutoForm.getFormSchema(formId, [form])  Client

This method getFormSchema is defined in AutoForm

Arguments

  • formId {String}

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:1076

AutoForm.getFormId()  Client

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:1088

AutoForm.selectFirstInvalidField(formId, ss)  Client

This method selectFirstInvalidField is defined in AutoForm

Arguments

  • formId {String}

The id attribute of the form

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(formId, ss) { ... autoform-api.js:1101

AutoForm._validateFormDoc(doc, isModifier, formId, ss, form, [key])  Client

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

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(doc, isModifier, formId, ss, form, key) { ... autoform-api.js:1155

setDefaults()  Client

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:1226


File: "inputTypes/value-converters.js" Where: {client}


({Date})  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:46

({Date})  Client

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:57

({Date})  Client

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:79

AutoFormvalueConverters.dateToNormalizedLocalDateAndTimeString(date, [timezoneId])  Client

This method is private This method dateToNormalizedLocalDateAndTimeString is defined in AutoForm.valueConverters

Arguments

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:97

AutoFormvalueConverters.stringToNumber(val)  Client

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:141

AutoFormvalueConverters.stringToBoolean(val)  Client

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:168

AutoFormvalueConverters.stringToDate(val)  Client

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:197


File: "components/quickForm/quickForm.js" Where: {client}


  undefined

Private Functions *
Takes a schema object and returns a sorted array of field group names for it

Arguments

  • ____ {any}

{Object} schemaObj Like from mySimpleSchema.schema()

Returns {String[]} Array of field group names

function getSortedFieldGroupNames(schemaObj) { ... components/quickForm/quickForm.js:90

  undefined

Returns the schema field names that belong in the group.

Arguments

  • ____ {any}

{String} groupName The group name

  • ____ {any}

{Object} schemaObj Like from mySimpleSchema.schema()

Returns {String[]} Array of field names (schema keys)

function getFieldsForGroup(groupName, schemaObj) { ... components/quickForm/quickForm.js:111

  undefined

Returns the schema field names that don't belong to a group

Arguments

  • ____ {any}

{Object} schemaObj Like from mySimpleSchema.schema()

Returns {String[]} Array of field names (schema keys)

function getFieldsWithNoGroup(schemaObj) { ... components/quickForm/quickForm.js:131


File: "autoform-events.js" Where: {client}


  undefined

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:58

  undefined

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:71