• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Application.cfc Form Validation

New Here ,
Oct 29, 2008 Oct 29, 2008

Copy link to clipboard

Copied

Hi all. I posted this question on the site I got the example from, but they removed my question for whatever reason so I'll try here:

Please click the link for the code: Click Here

I tried this example, and it works, however a couple of things I'm trying to figure out:

1. The validation errors change their order each time you re-submit, is there a way to control that?

2. I tried populating the form elements with what was posted, but the form isn't posting anything, and I'm looking to see if anyone else has this problem


Thanks.
TOPICS
Advanced techniques

Views

503

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 29, 2008 Oct 29, 2008

Copy link to clipboard

Copied

I didn't visit your page. The subject line suggests that you are trying to do form validation in an application.cfc file. Bad idea. Do it in another file somewhere.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 29, 2008 Oct 29, 2008

Copy link to clipboard

Copied

Hey.. Not sure what happened to my 2 points above. The preview looked fine before I submitted it. Weird!

Anywho.....

Thanks for your reply Dan.

This (amongst other code) is what they put in there:
<cffunction name="onError" returntype="void">
<cfargument name="exception" required="true" />
<cfargument name="eventName" type="String" required="true" />

<cfif isDefined('exception.StackTrace') AND isDefined('exception.errors')
AND exception.StackTrace contains 'coldfusion.filter.FormValidationException'>
<cfset session.validationError = exception.errors />
<cfset session.stFormData = duplicate( form ) />
<cflocation url="#cgi.HTTP_REFERER#" addtoken="false" />
<cfelse>
<cfthrow object="#exception#" />
</cfif>
</cffunction>

So,why would this be a bad idea?

- - - -
Oh, and if the above code makes it ok to add to Application.cfc, then my quesitons 1 and 2 were:
1. The validation errors return in different orders every time the form is posted, and was wondering how to control this.

2. I couldn't get the form to post any values.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 29, 2008 Oct 29, 2008

Copy link to clipboard

Copied

LATEST
> The validation errors return in different orders every time the form is posted, and was wondering how to control this.

You can't. That's one of the downsides of using cfform validation.

As to why your form didn't post any values, you're going to need to post your form code (from <cfform...> to </cfform>)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation