I need to show a list of validation errors in a popup.
I've disabled UI modification with <form data-parsley-ui-enabled="false"...
and subscribed to the "parsley:field:error" event, where I collect error information, and then on "parsley:form:validated" I display the popup, ofcourse only on the condition isValid() == false
.
But I am having problems with getting the actual error message in the "parsley:field:error" handler. The handler gets a single parameter containing an object, which so far I inspected to have several properties:
- $element - the actual jQuery field,
- constraints - list of constraints
- options.i18n - it has some raw error message strings which I can get iterating with an n variable like so:
obj.options.i18n.<LANGUAGE_CODE>.[obj.constraints[n].name]
, but they ocasionally contain placeholders (%s) and therefore are not suitable for display to the end user; and sometimes there's an array instead of a single string, which defeats the idea completely;
The question is, how do I get the actual error message which would got displayed if I hadn't disabled the UI?