ericmbarnard/Knockout-Validation — Issue #37: showAllMessages to take bool to hide all messages
Author: heliosPortal
Created: 2012-03-10 06:07:13+00:00
State: open

I have a scenario where I am preloading a form with some data for a new entity. The loader ends up assigning all fields from JSON returned from the server (hence setting isModified to true for all fields), but does not check if there is actually a value. The result is that those required fields with empty data end up with their validation message shown - when I really want it to behave as a 'new' form. It seems one solution is to allow showAllMessages to take a boolean as shown below - which would allow us to pass in false to hide all messages. Any thoughts?

result.showAllMessages = function (show) {
if (show == undefined) //default to true
show = true;
ko.utils.arrayForEach(validatables, function (observable) {
observable.isModified(show);
});
};

Thanks,
Scott