FormStore instance save() method

This method sends ready-to-save data changes to the server (normally using server.set, unless it's undefined, then with server.create) For a store with idProperty defined when the value of that property is falsy and allowCreate=true, uses server.create instead.

It returns a Promise which resolves (after server responds with the result and the model is updated) with true if save was actually performed (with errors or not) and false if save was skipped (i.e. no changes since last save or refresh or no changes ready to be sent as they failed validation or create is needed but allowCreate is false).

IMPORTANT: Both manual calls to save() and the auto-save facility will send all changed data properties that are not in error, regardless of whether other properties failed validation and model.status.canSave is false.

This method is often set up to run when user navigates away from the form (i.e. componentWillUnmount) or the app is paused so the user's work is saved.

Calls to save() while one is in progress are queued.

Note that FormStore does not have any built-in timeout facilities - it's up to the server.set/create methods to reject if no response is received from the server within some reasonable period of time.

FormStore instance save() method takes a single optional Object-type argument - saveOptions.

saveOptions

Option Data type Default Description
allowCreate Boolean false This option controls the behavior of save() when the model has a non-null idProperty and the value of that property is falsy, which means save() needs to call server.create instead of server.set. Your form may be set up to call save() when user navigates away from it to preserve their work. However, in a create scenario, submitting possibly partial data is undesireable. Therefore, by default, when save() needs to create and allowCreate=false, save() will do nothing. To enable save() to call server.create(), you must call save() with allowCreate: true. So be sure to set up your actual form Save button to do this.
saveAll Boolean false If true, save() will send the entire data object to server.set/create including any properties that failed validation and save will be performed even if no data has changed.
skipPropertyBeingEdited Boolean false When auto-save calls save() it sets this to true, which results in omitting the property that the user is currently editing from being sent to the server. See startEditing()/stopEditing() methods.
keepServerError Boolean false When auto-save calls save() it sets this to true so it doesn't clear the last error message from the server if any, which is what normally happens in every save() call right before the call to server.set/create. Note that even when this is true, the server error will still be updated or cleared but after the server responds, so the purpose of this parameter is to keep the UI from flickering during each auto-save.

You can include additional properties in saveOptions for use by the beforeSave callback, which receives the entire saveOptions object as its third argument.

results matching ""

    No results matching ""