Skip to main content
Participant
November 6, 2008
Answered

CFFORM errors object?

  • November 6, 2008
  • 1 reply
  • 986 views
The CFFORM documentation mentions an "errors" object that can be accessed via actionscript in Flash format. I can't get the sample code in the docs to work. Has anyone successfully accessed this object? Can you give me some more detail regarding it's structure and use? BOTTOM LINE: I would like to run some actionscript in the onSubmit event that would test for the existence of validation errors before running a flash remoting call.
This topic has been closed for replies.
Correct answer FlashHack
The are tons of comments in the asfusion link above, but check the one by Laura (dated August 22, 2005 at 9:28 PM). She mentions: "If you want to completely emulate the way cfform does it by default, call userOnError() (although it is one of those hacks that may change in the future)".

You can view the userOnError function code, by dumping the form object. It uses CFFormValidators.getInValidFields() to retrieve the error structure and display them in a pop-up. I do not how much of that is documented. But at least it gives you an idea how CF handles it.

Excellent! Thanks again. You are a gentleperson and a scholar.

1 reply

Inspiring
November 9, 2008
The older entries at asfusion.com are a very good resource for all things cfform/flash related. The Flex documentation is also useful.

http://www.asfusion.com/blog/entry/enabling-and-disabling-validation-in
http://livedocs.adobe.com/flex/15/asdocs_en/mx/validators/Validator.html

I do not do much work with cfform/flash. But here is a small example demonstrating the onError method. It is not meant to do anything but show the error object properties. As it uses cfformitem type="script" it requires MX 7.02+ (IIRC).



FlashHackAuthor
Participant
November 10, 2008
Thank you, mysterious stranger who roves the forums seeking programmers in distress! That certainly helps me get half-way there.

What I would like to do is "submit" the form using a flash remoting call attached to a button's onClick event. With the "isStructureValid" method you have shown me, I am able to stop the remoting call if there are errors (half my problem), but I am not sure how to produce an alert listing all the error messages. CFFORM produces this alert automatically if you actually submit the form, but I am not really submitting it. Is there a way to access this collection of errors outside of the onError method (which only seems to fire if you submit the form via the traditional method)? Thanks!
Inspiring
November 10, 2008
The are tons of comments in the asfusion link above, but check the one by Laura (dated August 22, 2005 at 9:28 PM). She mentions: "If you want to completely emulate the way cfform does it by default, call userOnError() (although it is one of those hacks that may change in the future)".

You can view the userOnError function code, by dumping the form object. It uses CFFormValidators.getInValidFields() to retrieve the error structure and display them in a pop-up. I do not how much of that is documented. But at least it gives you an idea how CF handles it.