Avoid double-quotes in field error messages JS code
This commit is contained in:
parent
d5a9aa6925
commit
e49a31df6a
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue