Context issues using CFFORM with CFC procedure calls

Posted on 2005-05-04
Last Modified: 2013-12-24
I may be out of luck, but it's worth asking:

I need to build a form with several required elements, but I use procedure calls to build these elements.  For instance one procedure call should build several <cfinput> tags.  But since all of the tags need to be on the same form, I can't start the cfform in the procedure call, creating a context error.

For example:
<cfform name="exam" method="post">
<cfoutput query="qGetQ">
       <cfinvokeargument name="pID" value="#qGetQ.question_id#">
       <cfinvokeargument name="pNum" value="#qNum#">

The problem is the procedure cannot see that I've started the <cfform> tag.  Error message:
 Context validation error for tag cfinput.
 The tag must be nested inside a cfform tag.

Is it possible at all to let the procedure see that the tag has been made in the calling page.  I checked and there is no Caller scope in a CFC procedures, and none of the other scopes seem to have any data related to the <cfform> tag.

Thanks for any input and suggestions
Question by:TimDg
    LVL 9

    Accepted Solution

    Hi Tim,

    Your question is a good one, and one that I've asked in the past as well. Here's the skinny: any "dynamic" writing of ColdFusion tags is not allowed, such as with CFFORM elements and other items such as CFQUERYPARAMs (those are the ones I've tried in the past). The problem is that while ColdFusion does support delayed evaluation (using the DE() function), it can't evaluate this type of situation because it will try to evaluate EVERYTHING in your output, not just the CFINPUT elements (i.e., words, HTML, etc...).

    But, all hope isn't lost. In my experience, using CFFORM really only gets you client-side validation routines,respectively, of which I've since replaced with my own JavaScript validation libraries. Dynamically creating forms is a very common task, and one that I use frequently, especially with "output" CFCs. I would try using a regular form, and build in a "handler" CFC for validation. If you would like a copy of my validation routines (they're public), I'll be happy to email them to you.


    LVL 1

    Author Comment

    That's about what I figured :)  We're not actually using CFFORM, but our own custom tag set that manages our form validation.  It's much more advanced than normal cfform, but again the tags are dependent.  We've been continuing to brainstorm and have come up with several work arounds, but none that would be as straight forward as I would like.  Something I suppose we'll continue working with.

    Thank you for your comments.

    Featured Post

    Network it in WD Red

    There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

    Join & Write a Comment

    This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
    In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now