JayEdgar
Posts: 77
|
Posted: 03/08/2012, 8:40 AM |
|
How can I get a count of the errors if a field marked Required is not filled in? I've done a bunch of searching.
I've tried $Results->Errors->Count(), print(r) the entire error block, etc., I can't find anything.
Of course I could turn off Required and do my own validation, and I really don't want to have to do that.
Thanks in advance,
Jay
|
|
|
DataDoIT
|
Posted: 03/08/2012, 10:09 AM |
|
The correct object would be $Container->Errors->Count().
However, it depends on -where- you're attempting to capture that.
Validation occurs in this order:
Field property settings (such as Required = Yes)
Field OnValidate event if one exists
Record OnValidate event if one exists
So there's no place that I can think of where you would be able to
capture the Required = Yes validation, unless you go into the .php code
and hack the generated code (don't do that ever).
Your best bet is to put all of your validation into the record form's
OnValidate event if you need to capture error counts and react upon that
count accordingly. We do this often so that we don't have to show a
gozillion error messages in the Error control, such as a long form with
lots of Required fields.
|
|
|
JayEdgar
Posts: 77
|
Posted: 03/08/2012, 10:49 AM |
|
That's disappointing, and seems like a big hole in the capabilities of CCS.
Thanks for the response, DDI. And I do, indeed, know to never hack the grayed out code. :o)
I submitted a help request. This is something the system should really be able to do.
Thanks again,
Jay
|
|
|
clahti2
Posts: 107
|
Posted: 03/08/2012, 7:58 PM |
|
yes agreed, there should be an onError event that you can write custom code to and bypass all the other crap.
|
|
|
phpminer
Posts: 28
|
Posted: 03/08/2012, 10:39 PM |
|
You can also get these error counts for empty fields by iterating through your form field objects
using javascript. I realize this may not be what you want, but it's better to deal with blank fields
within client-side code instead of through server-side code.
|
|
|
JayEdgar
Posts: 77
|
Posted: 03/09/2012, 2:13 AM |
|
In some cases that may be true, phpminer. However, with the refresh rate being very quick, this would really just increase development time. My budget for this project is rather strict, and I can't afford the time. Thanks for the thoughts.
Quote phpminer:
You can also get these error counts for empty fields by iterating through your form field objects
using javascript. I realize this may not be what you want, but it's better to deal with blank fields
within client-side code instead of through server-side code.
|
|
|
|