I've been neglecting my blog because I have been working on several large eCommerce projects over the last two months, but I found an issue that I think is worth asking the CF community about.
With the new features in CF8, I find myself wanting to use cfform and cfinput more for binding and Ajax features, but I keep running into issues with errors generated by ColdFusion.
My CFM file…
<cfset formlibrary = createObject('component','formlib') />
<cfform action="myscript.cfm" method="post">
<cfset formlib.printNameFields() />
<cfset formlib.printAddressField() />
My CFC file…
First name: <cfinput type="text" name="firstname" required="yes" message="First name is required." />
Last name: <cfinput type="text" name="lastname" required="yes" message="Last name is required." />
Line 1: <cfinput type="text" name="addr1" />
Line 2: <cfinput type="text" name="addr2" />
This code will generate a CF error because you cannot have a CFINPUT tag that is not nested inside a CFFORM tag. However, if the error did not fire, the generated source code sent to the browser would work! The error message that ColdFusion generates isn't really an error. ColdFusion just doesn't understand that I am outputting the form fields from a CFC that is inside the CFFORM tag.
This is a simple example of the problem, but what if I also wanted to use the CF8 type="datefield" CFINPUT? I can't have that in a CFC either. I also can't use any CF8 ajax binding on with CFINPUT tags.
For now, I am just putting the CFINPUT tags in the CFM file and not making the code as modular as I would like. It is frustrating, though, that I have to repeat code on various forms for name and address form fields.
Does anyone have a suggestion for this? Is there a way to suppress the ColdFusion error and let it just generate the code? Or am I missing something?