Tutorial: Form messages

Form messages

Form messages are used within the client to trigger and handle specific events on forms. You can listen to messages and publish them.

Form messages include validate, save, commit and rollback, which are described in the following.

validate

Signal listeners that they should validate.

save

Signal listeners that they should save, e.g. save object values on the runtime, or set references.

When saving fails, an Error instance is passed to the error callback. This might happen when a server side validation fails, a connection error occurs, etc. In order to distinguish between validation and other errors you can check the error using instanceof:

form.publish("save", function() {
    console.log("Form validated fine!");
}, function(err) {
    if (e instanceof mendix.lib.ValidationError) {
        console.log("Validation failed");
    } else {
        console.log("Some other error occured");
    }
});

commit

Signal listeners that they should commit, e.g. commit an object in the runtime.

rollback

Signal listeners that they should rollback, e.g. rollback an object in the runtime.