Question
Creating form element from within a component
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
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
