macromedia.coldfusion.advanced_techniques
[Top] [All Lists]

Creating form element from within a component

Subject: Creating form element from within a component
From: "jim1234"
Date: Thu, 4 Dec 2008 20:24:46 +0000 UTC
Newsgroups: macromedia.coldfusion.advanced_techniques

Hi all,

 I am trying to create a form element within a component function which is then 
called from a .cfm page which has the cfform tags.  I keep getting a context 
validation error for the form element tag.  Here is some sample code:

 <cfcomponent name="yourComponent">
    <cffunction name="createTag" returntype="string" access="public">

         <cfsavecontent variable="returnContent">
             <cfselect name="thisSelect">
                 <option value="0">Value 1</option>
             </cfselect>
         </cfsaveconten>

         <cfreturn returnContent>
     </cffunction>
 </cfcomponent>


 And in the .cfm page:

 <cfform>
   <cfinvoke component="yourComponent" method="createTag" 
returnVariable="returnContent"/>
   <cfoutput>#returnContent#</cfoutput>
 </cfform>

 The error occurs in the function and it says the cfselect must be within a 
cfform.  I tried the function without the save content and just set the 
output="yes" but the same error occurs.

 Any help appreciated in how to get around this.  Just putting the code in the 
.cfm is not an option for this.

 Any help appreciated.
 Jim


<Prev in Thread] Current Thread [Next in Thread>