diff --git a/tailbone/forms/core.py b/tailbone/forms/core.py index bd939272..ac17c1b4 100644 --- a/tailbone/forms/core.py +++ b/tailbone/forms/core.py @@ -904,10 +904,19 @@ class Form(object): # show errors if present error_messages = self.get_error_messages(field) if error_messages: + + # TODO: this surely can't be what we ought to do + # here..? seems like we must pass JS but not JSON, + # sort of, so we custom-write the JS code to ensure + # single instead of double quotes delimit strings + # within the code. + message = '[{}]'.format(', '.join([ + "'{}'".format(msg.replace("'", r"\'")) + for msg in error_messages])) + attrs.update({ 'type': 'is-danger', - # ':message': self.messages_json(error_messages), - ':message': error_messages, + ':message': message, }) # merge anything caller provided