Re: Creating form element from within a component
On Dec 4, 8:24 pm, "jim1234" <webforumsu...@xxxxxxxxxxxxxx> wrote:
> Hi all,
> I am trying to create a form element within a component function which is
> 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>
> <cfreturn returnContent>
> And in the .cfm page:
> <cfinvoke component="yourComponent" method="createTag"
> 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.
It's content parsing error... CF attempts to predict how your code is
going to be used, when you put <cfselect> in cfc function there is NO
way CF can enforce this function to be used ONLY inside <cfform> tag,
so it attempts to prevent runtime errors by NOT generating the