}
/**
- * Based on $el, get the first element with selector in this order:
- * 1. The element's direct sibling('s).
- * 3. The element's parent's children.
+ * Get:
+ * - Based on $el, the first element(s) corresponding to `formErrorSelector` in this order:
+ * 1. The element's direct sibling('s).
+ * 2. The element's parent's children.
+ * - Element(s) with the attribute `[data-form-error-for]` set with the element's id.
*
* This allows for multiple form errors per input, though if none are found, no form errors will be shown.
*
* @returns {Object} jQuery object with the selector.
*/
findFormError($el) {
+ var id = $el[0].id;
var $error = $el.siblings(this.options.formErrorSelector);
if (!$error.length) {
$error = $el.parent().find(this.options.formErrorSelector);
}
+ $error = $error.add(this.$element.find(`[data-form-error-for="${id}"]`));
+
return $error;
}