Observables

model property

Data type

Description

data

Observable Object

Model data. You can read and write to any properties as well as replace the entire object with new one.

dataErrors

Observable Object

Mirrors the structure of model.data but with null as the normal value of each property. Validation error messages can be placed in its properties.

propertyBeingEdited

Observable String

Name of the property currently in focus / being edited (as set by the startEditing() method).

saveNotification

Observable Object

saveNotification.active

Boolean

Set to true right after a save() is completed. This allows a confirmation message to be shown to the user. To drive its dismissal, the UI can set this property back to false.

saveNotification.status

String or null

Contains response.status from last server.set/create() response (i.e. typically 'ok' or 'error').

status

Computed Object (i.e. read-only Observable)

status.errors

Array

Array of error messages (from all properties in order in which data properties are enumerated) - useful to display a list of all validation errors at the top of the form. If there was an error in the last server request or an error message was returned in response.error, this (model.serverError) will be the first element in the array. model.serverError is cleared right before every call to server.get/set/create methods.

status.isReady

Boolean

True value indicates initial data load has been completed and user can start entering data. Once this becomes true, it always stays true and if model.options.idProperty is defined and that property in the data received from server is falsy, any calls to refresh() do nothing. Until this is true, it is best for the form to be grayed-out/masked.

status.isInProgress

Boolean

True value indicates either a save() or refresh() is in progress. When the form is grayed-out, this can be used to show a progress indicator.

status.canSave

Boolean

True value indicates that neither save nor refresh is in progress and there are no validation errors (except the one returned by the server in response.error). The form's Save Button can be rendered as grayed-out/flat (and click events from it ignored) when this is false.

status.hasChanges

Boolean

True value indicates there are unsaved changes in data (including invalid and in-progress ones). The form's Save Button can be rendered as grayed-out/flat (and click events from it ignored) when this is false.

status.isReadOnly

Boolean

By default, it's true when status.isReady is false. But you can provide to constructor a function in options.isReadOnly that will receive the status object (without isReadyOnly) and can return the value to place into this computed property. This allows you to take additional app status into account (i.e. user authentication state) in addition to isReady. Form fields can be rendered as read-only/disabled when this is true.

status.mustCreate

Boolean

True if model.options.idProperty is defined and the last value received from the sever for this property is falsy.

Any non-method properties on the model instance not listed above are considered private.

MobxSchemaForm will also create a fields object property on the model while it's mounted and may also create a validators object property.

Last updated