dotvvm icon indicating copy to clipboard operation
dotvvm copied to clipboard

ValidationErrors of a property should be cleared when the value changes

Open cafour opened this issue 8 years ago • 4 comments
trafficstars

Currently validationErrors are only cleared in the beforePostback event and that is not enough.

Imagine you have a modal dialog with a few form controls in it. The modal dialog allows you to edit properties of a CompanyDetail object that is located in the Detail property of the viewModel. These properties are being validated when you press the Save buttton. You left out required fields unfilled. If you close the modal dialog with validationErrors in it and open an entirely different CompanyDetail, the errors are still present in the modal dialog and the fields glow red, although they hold validvalues.

And that is why we should delete property's validationErrors when the value of the property changes.

cafour avatar Aug 17 '17 11:08 cafour

I'd implement the on-blur validation with the VDOM update because it requires complete validation overhaul.

exyi avatar Sep 13 '17 16:09 exyi

I agree. Currently the problem with the modal dialog can be solved by having validation enabled on the open button (which sends postback) with validation target set to something that's always validated as true (like the default Title property). This works because every postback with validation enabled clears all the errors in the viewmodel. It's a hack, sure, but for the time being it works.

cafour avatar Sep 15 '17 12:09 cafour

If a child object with validation errors is deleted, it seems to still throw client-side validation errors as if it was never deleted.

This seems like the same issue.

Your workaround really helps, though! Look forward to the rewrite.

symbiogenesis avatar Nov 07 '17 21:11 symbiogenesis

Related to #277 - we should discuss on the next sync call.

tomasherceg avatar May 10 '20 13:05 tomasherceg