<cfform> inside cfscript component

397 views Asked by At

I'm making components for a site and I'm wondering if I can return a cfform inside a return variable from a component and force coldfusion to output it parsed.

Obviously using "writeOutput(")" doesn't work. How could I achieve this? Thanks for your time!

2

There are 2 answers

0
Todd Sharp On

If you absolutely must do this (though I would shy away from it myself) you might want to have a look at this:

http://www.madfellas.com/blog/index.cfm/2011/1/26/Using-CFML-tags-in-cfscript-C4X-prototype

1
Dan Short On

You can't return a cfform, because tags can't be used inside of a CFScript based component. You're far better off doing something like this with a custom tag, which then references your component to get pieces to build out the form.

I would avoid (if at all possible) putting any cfform related pieces into a component, script-based or not.

If you did want to ultimately go this route, you'd need to put the cfform (and it's relevant pieces) either in another component that gets called by the script based one, or in an include that then is saved to a variable. All of the solutions related to trying to get the cfform into your CFC are going to be messy.