-
-
Notifications
You must be signed in to change notification settings - Fork 24
Displaying Errors
Luis Majano edited this page Nov 30, 2015
·
3 revisions
After validation you can use the same results object and use it to display the validation errors in your client side:
// store the validation results in the request collection
prc.validationResults = validateModel( obj );
<-- Display all errors as a message box --->
#getInstance( "MessageBox@cbMessagebox" )
.renderMessage( type="error", messageArray=prc.validationResults.getAllErrors() )#
If you want more control you can use the hasErrors()
and iterate over the errors to display:
<cfif prc.validationResults.hasErrors()>
<ul>
<cfloop array="#prc.validationResults.getErrors()#" index="thisError">
<li>#thisError.getMessage()#</li>
</cfloop>
</ul>
</cfif>
You can even use the results object in your views to get specific field errors, messagesbox, etc.