Work around some strange behaviour between trex/flask/chrome for modal forms.

The problem is that when you submit a modal form with a file in it, the error
handler for the modal form submission gets fired as well as the success
function - leading to you seeing both the "failed" and "success" labels, just
before the page reloads (if you returned action=reload from flask).

I didn't work out why, but the error is detectable and thus we can early-exit
from the error function. A debugging line was left in place, in case the
function ever early-exits at a time that is actually annoying.
Support modal forms passing a global_error for display.

This is useful if an error happens that isn't related to a form field or
otherwise can't be captured by form validation.