diff options
Diffstat (limited to 'web/widget/field.js')
-rw-r--r-- | web/widget/field.js | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/web/widget/field.js b/web/widget/field.js index 338895a..2df4332 100644 --- a/web/widget/field.js +++ b/web/widget/field.js @@ -5,13 +5,14 @@ define( [ + "acf2/dom", "acf2/error", "acf2/statusbar", "acf2/widget/abstract/base", "jquery", "underscore" ], - function(formatError, statusBar, Base, $, _) { + function(dom, formatError, statusBar, Base, $, _) { return Base.extend({ init: function( data, name, meta, level, editable, removable @@ -78,20 +79,7 @@ define( }) .fail(function(xhr) { - if (_.isString(xhr)) self.msg.text(xhr); - - else if (xhr.statusCode().status == 422) - self.msg.html( - _.reduce( - _.map( - $.parseJSON(xhr.responseText), _.escape - ), - function(a, b) { return a + "<br/>" + b; } - ) - ); - - else self.msg.text(formatError("Error", xhr)); - + dom.setText(self.msg, self.formatValidationError(xhr)); self.setStatus("invalid"); statusBar.validationReady(false); }); |