Fixed missing errors bug

This commit is contained in:
Ruben Vereecken 2014-08-04 19:57:13 +02:00
parent ca7b8ca10a
commit c165d46e17

View file

@ -11,6 +11,7 @@ module.exports.formToObject = (el) ->
module.exports.applyErrorsToForm = (el, errors, warning=false) ->
errors = [errors] if not $.isArray(errors)
missingErrors = []
for error in errors
if error.dataPath
prop = error.dataPath[1..]
@ -23,8 +24,10 @@ module.exports.applyErrorsToForm = (el, errors, warning=false) ->
message = error.message if error.formatted
prop = error.property
setErrorToProperty el, prop, message, warning
missingErrors.push error unless setErrorToProperty el, prop, message, warning
missingErrors
# Returns the jQuery form group element in case of success, otherwise undefined
module.exports.setErrorToField = setErrorToField = (el, message, warning=false) ->
formGroup = el.closest('.form-group')
unless formGroup.length