I'm trying to write a CFC to help with validation on some forms....
How can I use the <cfargument> tag to specify that the "form" scope structure
is required?
(i.e. I want to pass all the form name,value pairs in one arguement)
<cfinvoke component="#Application.CFCPath#.ValidateFormObj"
method="ValidateForm" argumentcollection="#form#" >
<cffunction name="ValidateForm" returntype="array" output="true">
<cfargument name="SomeData" required="yes" type="struct">
You are off to a good start with the argumentscollection=form. Not sure why
you want to return an array.
In fact, given that cfc's are a type of reusable code, and that not all forms
are the same, I'm not sure why you are even bothering with the extra complexity
of using cfc's.
sean69 - 30 Nov 2006 15:50 GMT
What I am trying to do is build a form validation cfc that I can just hand a
form to and have it hand me back an array valid or invalid field names.
currently I'm doing something like:
<input name="UserName" type="text" class="AdminField" id="UserName"
value="#UserName#" size="15" maxlength="15" />
<input name="_UserName" type="hidden"
value="String,min=8,max=12,NoProfane,NoMatchPasswd" />
I'm hoping to be able to do something MORE like: (though I'm not sure how to
this will be possible)
<input name="UserName" type="text" class="AdminField" id="UserName"
value="#UserName#" size="15" maxlength="15"
value="String,min=8,max=12,NoProfane,NoMatchPasswd" />
As you can see I want to be able to perform several different types of
validation on one name/data pair with as little extra code as possible....
Wouldn't it be nice to be able to html just the form - nothing else no cfif,
no extra hidden fields... hand it off to a cfc and have it come back valid or
invalid??
So anyway.... back to my question.
How do I specify in the cfargument that the required dataype IS the form
structure/collection?
Any thoughts?
-sean